Azzera filtri
Azzera filtri

plotting y-axis issue and wrong plot

3 visualizzazioni (ultimi 30 giorni)
Faisal Al-Wazir
Faisal Al-Wazir il 19 Ott 2022
Risposto: VBBV il 21 Ott 2022
hi i'm writing a code for newton's 2nd law were very the mass
the first plot is Mass VS Acc
2ND Force VS Acc
3RD Force VS Mass
but i'm thinking i'm doing something wrong especially in the last plot because it look like the first one+ my axies are a bit wrong too so can anyone explain
clear
clc
subplot(3,1,1)
hold on
for m=0:100:1000
a=linspace(20,220,1000);
f=m.*a;
plot(f)
title('mass V/s Acceleration');
xlabel('acceleration');
ylabel('mass')
end
legend m=0 m=100 m=200 m=300 m=400 m=500 m=600 m=700 m=800 m=900 m=1000
subplot(3,1,2)
hold on
for m=0:100:1000
a=linspace(20,220,1000);
f=m.*a;
plot(a,f)
title('Force V/s acceleration');
xlabel('acceleration');
ylabel('Force')
end
legend m=0 m=100 m=200 m=300 m=400 m=500 m=600 m=700 m=800 m=900 m=1000
subplot(3,1,3)
hold on
for m=linspace(0,1000,11)
a=linspace(20,220,1000);
M=linspace(0,1000,1000);
f=m.*a;
plot(M,f)
title('Force V/s Mass');
xlabel('mass');
ylabel('Force')
end
legend m=0 m=100 m=200 m=300 m=400 m=500 m=600 m=700 m=800 m=900 m=1000

Risposta accettata

VBBV
VBBV il 21 Ott 2022
subplot(3,1,3)
hold on
for m=linspace(0,1000,11)
  a=linspace(20,220,1000);
  M=linspace(0,1000,1000);
  f=M.*a;. % use M 
  plot(M,f)
  title('Force V/s Mass');
xlabel('mass'); 
ylabel('Force')
end

If you use M instead of m you can notice the difference.

Più risposte (1)

azarang asadi
azarang asadi il 19 Ott 2022
your m is 0:100:1000 which is a 1*11 but your a is 1*1000. It should be same size.
so m = 1:1000

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by