How to Fit Plot into Axes

6 vues (au cours des 30 derniers jours)
Jose Treviño
Jose Treviño le 25 Nov 2015
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');

Réponse acceptée

Walter Roberson
Walter Roberson le 25 Nov 2015
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');

Plus de réponses (1)

Jose Treviño
Jose Treviño le 25 Nov 2015
Thank you so much It worked like a charm!! you saved me hours of trial and error.

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by