Variable not recognized outside a loop
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Saad
am 28 Jul. 2014
Beantwortet: Saad
am 28 Jul. 2014
Dear All,
I have a simple but a long code. As you can see from the loop below, I am not a very efficient coder but my code works. However, the program does not recognize the matrix F inside the loop. How can I make the code recognize the F matrix which I need to use once the loop is finished. Thank you very much
Kind Regards
S
v=1;
for z=1:length(rc)
for j=1:length(r)
for i=1:length(n)
for k=1:length(d)
for l=1:length(s)
F(v,:)=[z, l, x];
end
end
end
end
end
1 Kommentar
Ben11
am 28 Jul. 2014
What do you mean by "does not recognize"? Can you show the error message you get?
Akzeptierte Antwort
Azzi Abdelmalek
am 28 Jul. 2014
Bearbeitet: Azzi Abdelmalek
am 28 Jul. 2014
Why do you think F is not recognized? Type
F
you will see the result
You have maybe forgotten the incrementation of v
v=1;
for z=1:length(rc)
for j=1:length(r)
for i=1:length(n)
for k=1:length(d)
for l=1:length(s)
F(v,:)=[z, l, x];
v=v+1;
end
end
end
end
end
0 Kommentare
Weitere Antworten (3)
dpb
am 28 Jul. 2014
v=1;
for z=1:length(rc)
for j=1:length(r)
for i=1:length(n)
for k=1:length(d)
for l=1:length(s)
F(v,:)=[z, l, x];
...
Set
F=zeros(maxV,length([z l x].'));
first. NB that your orientation of the vector must be column, not row or this will fail. z and x needs must be defined somewhere else, too, of course.
0 Kommentare
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!