フィルターのクリア

Gui doesnt work in windows

1 回表示 (過去 30 日間)
Nik Sam
Nik Sam 2016 年 6 月 5 日
回答済み: Walter Roberson 2016 年 6 月 5 日
Hello,
I made this GUI
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=0;
b=0;
plot(a,b,'ko');
text(a-0.5,b-0.5,[' (', num2str(a), ', ', num2str(b), ')'])
hold on
grid on
x = [-10000:0.1:10000];
y = [-10000:0.1:10000];
a=str2num(get(handles.edit1,'string')) ;
b=str2num(get(handles.edit2,'string'));
c=str2num(get(handles.edit3,'string'));
syms x y
eq3=a*x+b*y==c;
eq1=ezplot(a*x+b*y==c)
set(eq1,'color','blue','linestyle','-','linewidth',2)
title([])
hold on
If i run this from inside matlab its ok. But if I build .exe file and trying to run from windows only pushbutton doesnt work.

採用された回答

Walter Roberson
Walter Roberson 2016 年 6 月 5 日
x = [-10000:0.1:10000];
y = [-10000:0.1:10000];
Y = (c - a * x) / b;
Y(~ismember(Y, y)) = nan;
plot(x, Y);
But you are probably going to be disappointed, as it is likely that very few of the calculated Y values are going to exactly match one of your y values. I predict that you would be happier with
Y = (c - a * x) / b;
Y = round(Y,1);
plot(x, Y);
or
Y = (c - a * x) / b;
Y(Y < y(1) | Y > y(end)) = nan;
plot(x, Y);
or both combined.
Y = (c - a * x) / b;
Y = round(Y,1);
Y(Y < y(1) | Y > y(end)) = nan;
plot(x, Y);

その他の回答 (1 件)

Image Analyst
Image Analyst 2016 年 6 月 5 日
It's probably because ezplot() can't be compiled. Often little applets like that can't be included in a compiled app. Try to plot it manually with plot() or contour(). Don't declare x and y as syms. They don't need to be.
  3 件のコメント
Image Analyst
Image Analyst 2016 年 6 月 5 日
What do you mean you can't find a solution for it?
I gave you the solution for it: Use plot() instead of ezplot().
You'll have a lot more control over what you get anyway.
Walter Roberson
Walter Roberson 2016 年 6 月 5 日
Nothing in the Symbolic Toolbox can be compiled.

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

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by