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

1 view (last 30 days)
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)

Accepted Answer

David Sanchez
David Sanchez on 15 Apr 2014
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)

More Answers (0)

Categories

Find more on Entering Commands in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!