Why do I receive a subplot error?

1 visualización (últimos 30 días)
Kamryn Calloway
Kamryn Calloway el 8 de Oct. de 2021
Comentada: Star Strider el 9 de Oct. de 2021
figure(1)
hxl= subplot(scatter(height,leg));
lsline(hxl);
polyfit(height,leg,1);
title('Height v. Leg Length');
xlabel('Height (cm)');
ylabel('Leg Length (cm)');
%figure(2)
hxf= subplot(scatter(height,foot));
lsline(hxf);
polyfit(height,foot,1);
title('Height v. Foot Length');
xlabel('Height (cm)');
ylabel('Foot Length (cm)');
%figure(3)
hxs= subplot(scatter(height,speed));
lsline(hxs);
polyfit(height,speed,1);
title('Height v. Speed');
xlabel('Height (cm)');
ylabel('Speed (m/s)');
%figure(4)
lxs= subplot(scatter(leg,strl));
lsline(lxs);
polyfit(leg,strl,1);
title('Leg Length v. Stride Length');
xlabel('Leg Length (cm)');
ylabel('Stride Length (distance/stride)');
% Find the R^2 and p-value for each linear fit.
% Use command fitlm(x,y)
fitlm(height,leg)
fitlm(height,foot)
fitlm(height,speed)
fitlm(leg,strl)
>> WalkingSpeed
Error using subplot (line 197)
Requires valid axes handle for input.
Error in WalkingSpeed (line 49)
subplot(scatter(height,leg));

Respuesta aceptada

Star Strider
Star Strider el 8 de Oct. de 2021
That’s not how subplot works.
It should be something like this —
figure(1)
hxl = subplot(2,2,1);
scatter(height,leg)
lsline
% polyfit(height,leg,1);
title('Height v. Leg Length')
xlabel('Height (cm)')
ylabel('Leg Length (cm)')
%figure(2)
hxf = subplot(2,2,2);
scatter(height,foot)
lsline
% polyfit(height,foot,1);
title('Height v. Foot Length')
xlabel('Height (cm)')
ylabel('Foot Length (cm)')
%figure(3)
hxs= subplot(2,2,3);
scatter(height,speed)
lsline
% polyfit(height,speed,1);
title('Height v. Speed')
xlabel('Height (cm)')
ylabel('Speed (m/s)')
%figure(4)
lxs = subplot(2,2,4);
scatter(leg,strl)
lsline
% polyfit(leg,strl,1);
title('Leg Length v. Stride Length')
xlabel('Leg Length (cm)')
ylabel('Stride Length (distance/stride)')
That should work, although it may be necessary to tweak it to get the desired result.
.
  2 comentarios
Kamryn Calloway
Kamryn Calloway el 8 de Oct. de 2021
That worked thank you!
Star Strider
Star Strider el 9 de Oct. de 2021
As always, my pleasure!
.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by