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

1 次查看(过去 30 天)
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