MATLAB GUI axes(handles.axes1) does not work?

1 回表示 (過去 30 日間)
Tina
Tina 2013 年 8 月 18 日
コメント済み: Walter Roberson 2017 年 12 月 21 日
Hello;
I have this simple code that is supposed to draw the line having its slope and y intercept. But when I use axes(handles.axes1);
nothing happens. What should I do?
  2 件のコメント
the cyclist
the cyclist 2013 年 8 月 18 日
Can you post a self-contained example that we can run that shows what you mean, in context?
Tina
Tina 2013 年 8 月 18 日
編集済み: Image Analyst 2013 年 8 月 19 日
The GUI has a, b, c as edit text. When Solve push button is pressed, it should draw ax+by=c line on axes1.
function solve_Callback(hObject, eventdata, handles)
% hObject handle to solve (see GCBO)
% eventdata reserved - to be defined in atext future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=str2num(get(handles.a,'String'));
b=str2num(get(handles.b,'String'));
c=str2num(get(handles.c,'String'));
int=num2str(c/b);
slope=num2str(-a/b);
set(handles.y,'String',int)
set(handles.slope,'String',slope)
x=0:10;
y=c/b-a/b*x;
axes(handles.axes1);
xlabel('x');
ylabel('y');
guidata(hObject,handles);

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

回答 (1 件)

Image Analyst
Image Analyst 2013 年 8 月 19 日
axes() just switches focus to that particular axes control. It does not actually do any plotting at all. For that you'll need to use the plot() function
plot(x, y, 'bo-', 'LineWidth', 2, 'MarkerSize', 10);
grid on;
axis on;
ylabel('Y', 'FontSize', 30);
xlabel('X', 'FontSize', 30);
  4 件のコメント
Md Nafiul Islam
Md Nafiul Islam 2017 年 12 月 21 日
Dear, I have used the same code and I draw the line but I need two line of the same graph. Do anyone help me how I update this code to two line. TIA
Walter Roberson
Walter Roberson 2017 年 12 月 21 日
hold on
plot(x2, y2);

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

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ


Translated by