What does this operation do in matlab?
Mostra commenti meno recenti
This is very basic, but please forgive me since I'm only familiar with python and am trying to translate this code over from matlab. Basically, I have two variables:
```
var1 = [139,
140,
142,
143,
144,
154,
156,
157,
158,
159,
184,
185,
186,
187,
188,
189,
190,
191,
192]
var2 = [11,
12,
12,
15,
10,
8,
7,
10,
9,
6,
10,
9,
8,
15,
5,
17,
15,
18,
14,
18,
16,
13,
13,
17,
19,
4,
15,
18,
1,
4,
2,
3,
3,
1,
9]
```
All fine and good. Except that there is a separate variable, call it var3, which is defined as:
```
var3 = var1(var2);
```
which results in the value:
```
var3 = [184,
185,
185,
188,
159,
157,
156,
159,
158,
154,
159,
158,
157,
188,
144,
190,
188,
191,
187,
191,
189,
186,
186,
190,
192,
143,
188,
191,
139,
143,
140,
142,
142,
139,
158]
```
I'm confused as to what operation is occurring to get this resultant value of var3. Any help would be greatly appreciated.
Risposte (1)
John D'Errico
il 16 Apr 2023
0 voti
var2 is used as an index. It extracts the corresponding element of var1, thus creating var3.
Categorie
Scopri di più su Call Python from MATLAB in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!