Info
This question is closed. Reopen it to edit or answer.
please i want to know where is the mistake in the this code
1 view (last 30 days)
Show older comments
Part 1: Range and Time of Flight of a Cannonball
>> [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)’]);
part2
>> [hMaxAir,hMaxVac] = Q2_STNO(v,theta);
>> [x,y,range] = trajectoryInAir(v,theta);
>> [x,y,range] = trajectoryInAir(100,40);
>> plot(x,y);
>> axis equal;
Targeting the cannonball
>> [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;
A falling cannonball
>> v = Q4_STNO(m,d,tx);
>>d=0.47*0.5*1.2*6;
>> [v,vTerminal] = Q4e_STNO(m,d,tx);
please i want to know why this code i wrote it and not work any one can help me with it ????
7 Comments
Answers (1)
Walter Roberson
on 22 Nov 2013
You have
>>R=Q1_0123456(v,theta);
>>R=(v^2)*sin(2*theta)/g;
>>tof=Q1_0123456(v,theta);
>>tof=2*v*sin(theta)/g;
In both of those, you call Q1_0123456 to calculate a value, but you then immediately overwrite the value with your next command.
When you have a function of the form
[A, B] = C(D)
then you cannot "take turns" producing A or B from the function,
A = C(D);
B = C(D);
That second call will not produce the second output: it will recalculate the first output and replace B with that first output.
If your function is producing two outputs, you need to calculate the both at one time,
[A, B] = C(D);
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!