please i want to know where is the mistake in the this code

[R,tof] = Q1_STNO(v,theta);
G=9.81;
R=Q1_0123456(v,theta);
R=(v^2)*sin(2*theta)/g;
tof=Q1_0123456(v,theta);
tof=2*v*sin(theta)/g;
disp([Answer = num2str(R)]);
disp([Answer = num2str(theta)]);

Answers (6)

Your quotes are messed up in the disp statement. Try it like this instead:
fprintf('R Answer = %f\n', R);
fprintf('theta Answer = %f\n', theta);
In the first line you compute R and tof. In the third and fourth lines you overwrite R. In the fifth and sixth lines you overwrite tof. This means that the first, the third, and the fifth lines of code are entirely ignored and accomplish nothing. What is it you actually wish to calculate?
thanks alot guys that you answer me
what iam looking for where is the launch angle and is the acceleration due to gravity? but still give me error in line 1
Undefined function or variable 'v'.
Error in part1 (line 1) [R,tof] = Q1_STNO(v,theta);

1 Comment

So give a value to v before you call that function. How is it supposed to know what v is unless you tell it?
function f = Q1_0123456(v,theta)
[R,ToF] = Q1_STNO(v,theta);
g=9.81;
R=Q1_0123456(v,theta);
R=(v^2)*sin(2*theta)/g;
tof=Q1_0123456(100,30);
tof=2*v*sin(theta)/g;
fprintf('R Answer = %f\n', R);
fprintf('theta Answer = %f\n', theta);
this is how i wrote it and still have wrong run please help

1 Comment

Is it your intent to call this recursively? Because Q1_0123456() calls itself from inside itself.
[hMaxAir,hMaxVac] = Q2_STNO(v,theta);
[x,y,range] = trajectoryInAir(v,theta);
[x,y,range] = trajectoryInAir(100,40);
plot(x,y);
axis equal;
and this is second Question please check for me
calculate the maximum height reached by a cannonball both with and without drag due to air resistance
[vmin,vmax] = Q3_STNO(X,W);
vmin=Q3_0123456(X,W);
vmin=[x,y,range] = trajectoryInAir(0.1,0.5);
vmax=[x,y,range] = trajectoryInAir(0.5,1);
plot(x,y);
axis equal;
and this is the third :)

This question is closed.

Asked:

on 16 Nov 2013

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!