Restarting the comand "for"

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

回答(1 个)

JESUS DAVID ARIZA ROYETH
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

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by