05-26-2013 11:44 AM
Hi,
I want to start a Foor loop from 2 and end it to 5. Meaning that any process inside the foor loop must start from second loop and end till 5th loop. This is how my question would like in Matlab.
for i=2:5
Help is appreciated.
Solved! Go to Solution.
05-26-2013 11:51 AM
Wire a 4 to N and add two to the value coming from the iteration terminal.
05-26-2013 12:08 PM
This is what I'm trying to do
p=zeros(4,4);
for i=2:4
for j=2:4
p(i,j)=i+j
end
end
result should be
p =
0 0 0 0
0 4 5 6
0 5 6 7
0 6 7 8
05-26-2013 12:13 PM
05-26-2013 12:33 PM
Did what you told, getting correct values but how would I get the result in a matrix form as
p =
0 0 0 0
0 4 5 0
0 5 6 0
0 0 0 0
I've attached a screenshot of what I did and what I'm geting.
05-26-2013 12:40 PM
You did not follow the instructions you were given. Wire 4 to the N terminals.
Lynn
05-26-2013 12:42 PM
05-26-2013 12:44 PM
Wired!
This is what I'm getting now
05-26-2013 01:26 PM - edited 05-26-2013 01:27 PM
@NapDynamite wrote:
This is what I'm trying to do
p=zeros(4,4);
for i=2:4
for j=2:4
p(i,j)=i+j
end
end
result should be
p =0 0 0 0
0 4 5 6
0 5 6 7
0 6 7 8
You should be aware that in LabVIEW the first element has index 0, while e.g. in matlab the first element has index 1
To get the above result, here's what you could do. (your elements are symmetric. If they are not, you might need to swap the index inputs, depending on what you actually want)
Here's what you could do... (initialize array replaces the "zeroes" function.
05-26-2013 01:56 PM
Have you used Replace array or Insert Into Array inside the second loop?
Can you please send me this VI? 😞