does not show off the plot properly

조회 수: 1 (최근 30일)
Suresh Dahal
Suresh Dahal 2017년 9월 4일
답변: Walter Roberson 2017년 9월 4일
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
Suresh Dahal
Suresh Dahal 2017년 9월 4일
I found the working solution in another thread.
plot(t,ones(size(t)) * ac)

댓글을 달려면 로그인하십시오.

답변 (1개)

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by