- #1

- 40

- 0

So imagine an equation that has two indexes, and that can be expressed as a matrix, how can I do something like this in Matlab? using a for cycle?

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Thread starter Deathcrush
- Start date

- #1

- 40

- 0

So imagine an equation that has two indexes, and that can be expressed as a matrix, how can I do something like this in Matlab? using a for cycle?

- #2

Mark44

Mentor

- 35,052

- 6,791

Can you give us an example? What you've said is on the vague side.

- #3

- 40

- 0

like for example, if I have I_{ij}=v_{i}/v_{j} considering that I know v for every i or j

- #4

- 297

- 2

So imagine an equation that has two indexes, and that can be expressed as a matrix, how can I do something like this in Matlab? using a for cycle?

Often unnecessary to use a for loop, but you can always do things like this:

Code:

```
a = [1 2 3; 4 5 6; 7 8 9];
for i = 1:3,
for j = 1:3,
a(i,j)
end
end
```

- #5

- 40

- 0

- #6

- 297

- 2

I'm rusty on my MATLAB, but something like this perhaps?like for example, if I have I_{ij}=v_{i}/v_{j}considering that I know v for every i or j

Code:

```
for i = 1:length(v),
for j = 1:length(v),
r(i,j) = v(i)/v(j);
end
end
r
```

- #7

- 40

- 0

oh thanks a lot Grep, that REALLY helped me, now I've finished :)

Share: