Reputation: 21
Can someone tell me how can I plot a 3d graph in matlab if I have the data in a single file in three column format like this:
48.000000 0.017723 0.400000
48.500000 0.017467 0.400000
49.000000 0.017209 0.400000
49.500000 0.016943 0.400000
50.000000 0.016664 0.400000
50.500000 0.016361 0.400000
51.000000 0.016022 0.400000
51.500000 0.015628 0.400000
52.000000 0.015151 0.400000
52.500000 0.014539 0.400000
53.000000 0.013709 0.400000
Each column represents a variable (3 axis) and all 3 vary.
Upvotes: 1
Views: 17498
Reputation: 11
just try this code,
a=importdata('file.txt');%file_name.extension
plot3(a(:,1),a(:,2),a(:,3));
it's very easy and works fine too.
Upvotes: 1
Reputation: 11168
fid=fopen('data.txt');
XYZ=fscanf(fid,'%f %f %f',[3 Inf]);
fclose(fid);
plot3(XYZ(1,:), XYZ(2,:), XYZ(3,:));
Upvotes: 3