For Loop无法正常工作...我想显示数据

时间:2013-07-04 13:15:25

标签: matlab loops for-loop

我正在编写一个程序来决定用户输入在数据文件中的含义。我怎么能这样做?

代码:

close all, clear all, clc;

%asking the user to input data
L=input('\Enter the value of length, L: ');

%load data file
load data.dat;
module=data(:,1);
l=data(:,2);

n=length(l);

for i=1:1:n
   if L==l(i);
       fprintf('\nLength = %.0f is found in the standard specification', l(i));
   else
       fprintf('\nLength = %.0f is NOT found in the standard specification', L);
   end
end

数据文件:

1  300
2  591
3  752
4  801
5  1002
6  1200
7  1678
8  2190

0 个答案:

没有答案