How to fix : invalid first data argument

This is my code :
v01 = get(handles.vel1,'string')
v02 = get(handles.vel2,'string')
v03 = get(handles.vel3,'string')
v04 = get(handles.vel4,'string')
ct01 = get(handles.ct1,'string')
ct02 = get(handles.ct2,'string')
ct03 = get(handles.ct3,'string')
ct04 = get(handles.ct4,'string')
X = [v01, v02, v03, v04];
Y = [ct01,ct02, ct03, ct04];
plot(X,Y)
I am calling input data from edit boxes v01, v02,v03 and v04 to be plotted against calculated values ct01,cto2,cto3 and cto4 resp.
I am not able to plot the data, moreover, it generates error: Error using plot Invalid first data argument

 采纳的回答

All of the variables v01, etc are strings (which is clear because that is what you are requesting from the edit boxes). But only numeric values can be plotted, not strings. So you need to convert the strings to numeric. I would recommend using str2double:
X = str2double({v01,v02,v03,v04});

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by