简体   繁体   中英

MatLab help! Error using plot3 Not enough 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
Not enough input arguments.

Where am I going wrong here? my data file is just columns of doubles (hence %f )

This is one of those cases where the error isn't very informative. The problem here isn't that there aren't enough input arguments, it's that they are of the wrong type...

Your problem is that textscan actually returns the loaded data in a 1-by-N cell array , where N is the number of columns (ie format specifiers, like %f ) in your file. Each cell holds one column of data. You need to extract the contents of the cells using curly braces in order to pass it to plot3 , like so:

plot3(data{5}, data{6}, data{7});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM