Restarting the comand "for"

조회 수: 1 (최근 30일)
Leonardo Barbosa Torres dos Santos
답변: JESUS DAVID ARIZA ROYETH 2019년 11월 28일
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
JESUS DAVID ARIZA ROYETH 2019년 11월 28일
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