Filter löschen
Filter löschen

does not show off the plot properly

1 Ansicht (letzte 30 Tage)
Suresh Dahal
Suresh Dahal am 4 Sep. 2017
Beantwortet: Walter Roberson am 4 Sep. 2017
Hi, I am trying to plot the following code, but when I hit plot command the constant acceleration line does not appear on the graph, is there something I am missing?? thanks in advance.
function []=plot_a(tmax,s0,v0,ac)
t=0:0.1:tmax
s=s0+v0.*t+0.5*ac*t.^2
v=sqrt(v0^2+2*ac*(s-s0))
ac=(s-s0-v0*t)/(0.5*t.^2)
figure
plot(t,ac)
end
  1 Kommentar
Suresh Dahal
Suresh Dahal am 4 Sep. 2017
I found the working solution in another thread.
plot(t,ones(size(t)) * ac)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 4 Sep. 2017
You have
ac=(s-s0-v0*t)/(0.5*t.^2)
You used the mrdivide / operator, when you wanted the ./ divide operator

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by