Error using plot Conversion to double from cell is not possible.

20 ビュー (過去 30 日間)
rasen58
rasen58 2013 年 6 月 11 日
I don't why this isn't working.
I get an error on
a = plot (x1,y1);
which is at the end of my code.
function calc_Callback(hObject, eventdata, handles)
% hObject handle to calc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% blah = get(handles.calc, 'string');
set(handles.x2, 'string', 'hi');
XX1 = get(handles.x1, 'string');
YY1 = get(handles.y1, 'string');
RR1 = get(handles.r1, 'string');
XX2 = get(handles.x2, 'string');
YY2 = get(handles.y2, 'string');
RR2 = get(handles.r2, 'string');
XX3 = get(handles.x3, 'string');
YY3 = get(handles.y3, 'string');
RR3 = get(handles.r3, 'string');
% x1 = X1{1}; %getting the contents of each var
x1 = XX1;
y1 = YY1{1};
r1 = RR1{1};
%x2 = X2{1};
x2 = XX2;
y2 = YY2{1};
r2 = RR2{1};
x3 = XX3{1};
y3 = YY3{1};
r3 = RR3{1};
min = r1;
disp(['r1 ' num2str(min)]);
disp(['r2 ' num2str(r2)]);
if(min > r2)
min = r2;
end
if (min > r3)
min = r3;
end
temp = min;
min = temp/10;
disp(x1);
hold on
a = plot (x1,y1);
%b=plot(X2,Y2);
  1 件のコメント
Matt J
Matt J 2013 年 6 月 11 日
編集済み: Matt J 2013 年 6 月 11 日
In debug mode, do
K>> whos x1 y1
right before the last line and show us the output.

サインインしてコメントする。

採用された回答

Andrew Reibold
Andrew Reibold 2013 年 7 月 16 日
You are trying to plot a 'cell'. I believe the plot command only works for doubles.
Convert the cell to a double first.

その他の回答 (1 件)

David (degtusmc)
David (degtusmc) 2013 年 7 月 16 日
編集済み: David (degtusmc) 2013 年 7 月 16 日
As Andrew mentioned above, I believe is because you are trying to plot a cell. If you want to convert from cell to double you could do the following:
cell2mat -> mat2str -> str2num %type help followed by the function if in doubt
I know this is probably not the most efficient way, but you should be able to figure it out with one of the conversions. Hope this helps.

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by