How to Fit Plot into Axes

Hello, I'm very new to MatLab since I have exactly 2 days of using it. I began to get familiar doing and modifying some coding. Hoewever, I'm having trouble fitting a plot's output into the axes created at the GUI. I attach code and screenshot below) I wanna know how to make them fit in to the axes without the plot doing what it likes. Thank you very much in advance.
function pushbutton1_Callback(hObject, eventdata, handles)
sliderVal1=get(handles.Prslider,'Value');
Pr = [sliderVal1]; % Choose Prandtl
sliderVal2=get(handles.NusselSlider,'Value');
etaMax = [sliderVal2]; % Choose etaMax
sliderVal3=get(handles.lengthslider,'Value');
xm = [sliderVal3];
solinit = bvpinit(linspace(0,etaMax,8),...
[0, 0, 0, 0, 0]);
sol = bvp4c(@BlasiusT, @BlasiusTbc,...
solinit, [], Pr);
eta = linspace(0, etaMax);
y = deval(sol, eta);
subplot(2, 1, 1);
plot(eta, y(1,:),'--k',eta,y(2,:),'-k',eta,...
y(3,:),'Color',[0.9,0.1,0.1]);':k';
xlabel('\eta');
ylabel('y_1, y_2, y_3');
legend('Stream function f = y_1',...
'Velocity, df/d\eta = y_2', ...
'Shear, d^2f/d\eta^2 = y_3');
subplot(2, 1, 2);
plot(eta, y(4,:), '--k', eta, y(5,:), 'Color',[0,0.1,0.9]);':k';
axis([0 xm 0 2]);
legend('Temperature, T^* = y_4',...
'Heat flux, dT^*/d\eta = y_5');
xlabel('\eta');
ylabel('y_4, y_5');

 采纳的回答

Before, set up with
pan1 = uipanel('Units','normal', 'Position', [0 0 3/4 1]);
and place the sliders outside this region. You might find it easier to create a second uipanel to put the sliders in.
Then with that set up, you can do your calculations and then
ax1 = subplot(2, 1, 1, 'Parent', pan1);
plot(ax1, eta, y(1,:),'--k',eta,y(2,:),'-k',eta,...
y(3,:),'Color',[0.9,0.1,0.1]);':k';
xlabel(ax1, '\eta');
ylabel(ax1, 'y_1, y_2, y_3');
legend(ax1, 'Stream function f = y_1',...
'Velocity, df/d\eta = y_2', ...
'Shear, d^2f/d\eta^2 = y_3');
ax2 = subplot(2, 1, 2);
plot(ax2, eta, y(4,:), '--k', eta, y(5,:), 'Color',[0,0.1,0.9]);':k';
axis(ax2, [0 xm 0 2]);
legend(ax2, 'Temperature, T^* = y_4',...
'Heat flux, dT^*/d\eta = y_5');
xlabel(ax2, '\eta');
ylabel(ax2, 'y_4, y_5');

更多回答(1 个)

Jose Treviño
Jose Treviño 2015-11-25

0 个投票

Thank you so much It worked like a charm!! you saved me hours of trial and error.

类别

帮助中心File Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by