0

我正在使用 gui 并在我的按钮单击功能中尝试绘制一些东西,但我得到了错误

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

我是 matlab 新手,所以不太清楚为什么,我得到了 gui 给我的列表的第一个值。不起作用的行是最后一行。

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}; 
x1 = XX1;    
y1 = YY1{1}; %needed to do this because I was getting an error that said
r1 = RR1{1}; % Undefined function 'abs' for input arguments of type 'cell'.
%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);
4

1 回答 1

2

我发现了原因。我需要做

x2 = XX2{1}; 

获取 gui 返回的数组的第一个值

于 2013-06-11T22:17:06.700 回答