store the data in dat file with loop function
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!