필터 지우기
필터 지우기

Variable not recognized outside a loop

조회 수: 3 (최근 30일)
Saad
Saad 2014년 7월 28일
답변: Saad 2014년 7월 28일
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
Ben11
Ben11 2014년 7월 28일
What do you mean by "does not recognize"? Can you show the error message you get?

댓글을 달려면 로그인하십시오.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 7월 28일
편집: Azzi Abdelmalek 2014년 7월 28일
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

추가 답변 (3개)

dpb
dpb 2014년 7월 28일
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.

Saad
Saad 2014년 7월 28일
It says " ??? Undefined function or variable 'F'."
Thanks to the output "F" I managed to build another code below the loop. Now for some reasons, F can not be used outside the loop because it is not recognized- I must have missed something. Any advice is much appreciated. Thank you
S

Saad
Saad 2014년 7월 28일
Thank you Azzi. I did increment v but I deleted it by mistake. Thanks a lot for your help
Rgds
Saad

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by