matlab中若是想从循环语句中直接返回该怎么弄

来源:百度知道 编辑:UC知道 时间:2024/06/10 02:38:54

please use the break order

for Example

The example below shows a while loop that reads the contents of the file fft.m into a MATLAB? character array. A break statement is used to exit the while loop when the first empty line is encountered. The resulting character array contains the M-file help for the fft program.

fid = fopen('fft.m','r');
s = '';
while ~feof(fid)
line = fgetl(fid);
if isempty(line), break, end
s = strvcat(s,line);
end
disp(s)

that's ok