MATLAB initial velocity graph

조회 수: 8 (최근 30일)
Blake Sewell
Blake Sewell 2020년 10월 14일
답변: Gaurav Chaudhary 2020년 11월 3일
I have completed the first dot point as follows:
disp ('Initial Velocity')
disp ('Displacement Input')
prompt1= 'Initial displacement (metres): ';
s0 = input(prompt1); %s0=10 metres
prompt2= 'Final displacement (metres): ';
s = input(prompt2); %s=10 metres
prompt3= 'Final time (seconds): ';
t = input(prompt3); %0.8 seconds
v0 = ((s-s0)+(1/2).*(981/100).*t.^2)/t; %initial velocity equation
disp ('Result:')
disp ('Initial Velocity: ')
disp (v0)
However I am stuck on doing the second point, this is my code so far:
s0=10;
s=10;
t = 0.5:0.1:1.5;
v0 = ((s-s0)+(1/2).*(981/100).*t.^2)/t;
plot (v0, t)
Any help is greatly appreciated thank you!!

답변 (1개)

Gaurav Chaudhary
Gaurav Chaudhary 2020년 11월 3일
Hello,
I understand the issue you are facing where the velocity is not a 1D array. To make velcoity a 1D array please use the dot(.) operator.
For Example:
for the following statement the output is a double datatype
>>v0 = ((s-s0)+(1/2).*(981/100).*t.^2)/t;
V0 can be changed to a 1D array using the following command using dot operator
>>v0 = ((s-s0)+(1/2).*(981/100).*t.^2)/.t;
This should solve the issue you are facing.

카테고리

Help CenterFile Exchange에서 Visualization에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by