how to plot a graph from a data file

3 views (last 30 days)
loc
loc on 31 Jan 2012
I've data input file name "data.txt" formed:
"Measured Data
23-Dec-2011
t,f(t)
1,12.9
2,11.3
3,10.6
4,11.2
5,10.9
6,7.5"
but i don't know how to plot this file,i got wrong graph,here is code:
filename = input (' Enter your file name : ','s');
fid = fopen(filename,'r');
if fid == -1
disp('File open not successful')
else
while feof(fid) ==0
aline = fgetl (fid);
[num1, num2] = strtok(aline);
a = str2num (num1);
b = str2num(num2);
plot(a,b,'ob');
hold on
end
closeresult = fclose(fid);
if closeresult == 0
disp ('File close successful')
else
disp ('File close not successful')
end
end
* Error is :*
??? Error using ==> plot
Vectors must be the same lengths.

Answers (1)

Walter Roberson
Walter Roberson on 31 Jan 2012

Categories

Find more on Get Started with MATLAB 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!