how to make a computer go to a line in mfile for a repeat execution

조회 수: 1 (최근 30일)
segun
segun 2014년 4월 15일
답변: David Sanchez 2014년 4월 15일
Hi, I need hints on codes to use to make a computer execution go to a particular line in mfile and repeat the program. example B=[2 4 6 8]; C=[1.5 3 4 5.6]; A = sum(B-C); if A>1; g to say line 3 ? else disp(A)

채택된 답변

David Sanchez
David Sanchez 2014년 4월 15일
Matlab does not have that kind of implementation. On the other hand, you can do a work around using conditionals, either whiles or ifs.
For example, instead of
B=[2 4 6 8];
C=[1.5 3 4 5.6];
A = sum(B-C);
if A>1
go to say line 3 ?
else
disp(A)
end
You might do: ( I know the example has no sense, but it's to take your lines as an example)
A = 10;
while A>1
B=[2 4 6 8];
C=[1.5 3 4 5.6];
A = sum(B-C);
end
disp(A)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by