필터 지우기
필터 지우기

Matlab app designer isn't plotting on the UI axes, and actually isn't plotting any results at all.

조회 수: 2 (최근 30일)
I have a function assigned for when the button is pushed; the code looks like this:
function FirewhenreadyButtonPushed(app, event)
c=299792458;
if app.ExcitationShapeDropdown.Value=="Gaussian"
gaussian=1;
else
gaussian=0;
end
if app.IonizationShapeDropdown.Value=="Gaussian"
gaussianIon=1;
else
gaussianIon=0;
end
if app.AtomDropDown.Value=="Sr I"
A=2.01e8;
w0=4.087e15;
elseif app.AtomDropDown.Value=="Rb I"
A=0;
w0=0;
end
s0=1e-11;
t=app.TimeField.Value*10^-9;
diameter=app.ExcitationDiameterField.Value*10^-3;
energy=app.ExcitationEnergyField.Value*10^-6;
monkey=app.ExcitationDurationField.Value*10^-9;
delta=2*pi*c/(app.ExcitationWavelengthField.Value*10^-9)-w0;
IonE=app.IonizationEnergyField.Value*10^-6;
Ionmonkey=app.IonizationDurationField.Value*10^-9;
Iondiameter=app.IonizationDiameterField.Value*10^-3;
bandwidth=app.ExcitationBandwidthField.Value/(2*pi);
[time,P]=RK4BlochGUI(s0,t,diameter,energy,monkey,delta,A,w0,IonE,Ionmonkey,Iondiameter,bandwidth,gaussian,gaussianIon);
plot(app.UIAxes,time,P(1,:),'c')
hold on
plot(app.UIAxes,time,P(2,:),'g')
plot(app.UIAxes,time,P(3,:),'k')
hold off
end
There is no issue with the outside function called. Outside of app designer, it works perfectly well, and plotting it goes without a hitch.
But even when I change the code to something like this:
x=linspace(1,10);
y=3*x;
scatter(app.UIAxes,x,y);
it still won't plot. This looks correct; what the heck is going on?
  댓글 수: 1
VBBV
VBBV 2023년 6월 12일
이동: VBBV 2023년 6월 20일
can you explain your question more clearly? what is section of below code got to do with code present in function ? They appear to be unrelated. Do you see graphs on plotting axes when you press the pushbutton ? if possible can you share the code ?
x=linspace(1,10);
y=3*x;
scatter(app.UIAxes,x,y);

댓글을 달려면 로그인하십시오.

답변 (1개)

Sandeep Mishra
Sandeep Mishra 2023년 6월 15일
Hello William,
I understand that you are trying to plot three graphs using UIAxes in app designer.
In MATLAB, "hold(ax,_)" function can be used to hold the state of "ax" axes and in the second parameter you can set 'on' or 'off'.
You can implement your plotting function similar to the below example
% Plot1
t = [1 2 3 4 5 6 7 8];
z = [2 3 4 5 6 7 8 9];
plot(app.UIAxes, t,z,'c');
% Plot2
hold(app.UIAxes, 'on')
g = [1 2 3 4 5 6 7 8];
h = [3 4 5 6 7 8 9 10];
plot(app.UIAxes, g,h,'g');
% Plot3
c = [1 2 3 4 5 6 7 8];
d = [0 1 2 3 4 5 6 7];
plot(app.UIAxes, c,d,'k');
hold(app.UIAxes, 'off')
You can refer to the below documentation to learn more about "hold" in MATLAB

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by