store the data in dat file with loop function
显示 更早的评论
the question is : there a machine for n piece of pipe. Each pipe should measure weight and length and save as pipe.dat file. weight should keep between 4.5 to 5.1 and length should be 15.3 and 15.4. I have to count how much piece of pipe is reject there. For example, like ,if i have
4.64 15.30
5.21 15.36
4.79 15.39
first column with weight second with weight . And should be display : 'There were 1 rejects.'
weight = rand*(5.3-4.3)+4.3;
length = rand*(15.6-15.1)+15.1;
for i = 1:n
weight([n,1]);
length([n,2]);
save ('pipe.dat','-ascii', '-tabs');
load pipe.dat;
if weight >= 4.5 && weight <=5.1 && length >= 15.3 && length <=15.4
disp('good')
else
disp('There were %d rejects',n)
end
end
I try to put weight in first column and length in second and save it in pipe.dat but it fail because i guess my code for creating data is wrong.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Mathematics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!