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.

Antworten (1)

John D'Errico
John D'Errico am 16 Apr. 2023

0 Stimmen

var2 is used as an index. It extracts the corresponding element of var1, thus creating var3.

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 16 Apr. 2023

Beantwortet:

am 16 Apr. 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by