MatLab help! Error using plot3 Insufficient input arguments
fid =fopen(datafile.txt','r');
data = textscan(fid, '%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f');
plot3(data(:,5),data(:,6),data(:,7))
fclose(fid);
I am getting the error:
Error using
plot3
Insufficient input arguments.
Where am I going wrong here? my datafile is just columns of twins (hence %f
)
source to share
This is one of those cases where the error is not very informative. The problem here is not that there are not enough input arguments, but that they are of the wrong type ...
Your problem is that it textscan
actually returns the loaded data in a 1-by-N cell array , where N is the number of columns (like format specifiers, for example %f
) in your file. Each cell contains one column of data. You need to extract the contents of the cells using curly braces in order to pass it plot3
, for example:
plot3(data{5}, data{6}, data{7});
source to share