Restarting the comand "for"

1 view (last 30 days)
Leonardo Barbosa Torres dos Santos
Dear, I need a help.
I would like that: if a condition is met, the loop is restarted.
follow below the command that I put
Phi = 0;
for m1 = 0.0001:0.01:0.1
statements
if (reeal ~= 0)
fileID = fopen('C:\Users\real.dat','a');
formatSpec = '%1.15e\t %1.15e\r\n';
fprintf(fileID,formatSpec,...
Phi_degree,...
m1);
fclose(fileID);
Phi_degree = Phi_degree+5;
m1 = 0.0001;
else
end
end
The problem is that this way it does not reset the value m1. It continues as if I had not set m1 = 0.0001
Could you help me, please ?

Answers (1)

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH on 28 Nov 2019
solution:
a=true;
while a
for m1 = 0.0001:0.01:0.1
statements
if (reeal ~= 0)
fileID = fopen('C:\Users\real.dat','a');
formatSpec = '%1.15e\t %1.15e\r\n';
fprintf(fileID,formatSpec,...
Phi_degree,...
m1);
fclose(fileID);
Phi_degree = Phi_degree+5;
m1 = 0.0001;
break;
else
end
end
a=m1==0.0001;
end

Categories

Find more on Programming 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!