Hey guys please i need help with this. i am trying to have this function plot a graph of (a,r). The graph should be a curve but it gives me just a point. I don't know what i did wrong!
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Brenda Egbe
am 29 Okt. 2018
Kommentiert: madhan ravi
am 29 Okt. 2018
function [r] = range_calculator(a,v)
%UNTITLED Summary of this function goes here
% Takes angle vector and an 8 value velocity vector as inputs and calculates the range,
%and plots a graph of range vector versus angle vector for each velocity.
g=9.9;
a=0:0.05:pi/2;
v=linspace(50,100,8);
for k=1:length(v)
r(k)=(v(k).^2/g).*sin(2.*a(k));
end
plot(a(k),r(k),'--r*')
grid on
title('The initial velocity is v(k)')
xticks(-0.4:0.2:1.8)
yticks(0:50:800)
xlabel('Cannon Angle')
ylabel('Range,Meters')
end
0 Kommentare
Akzeptierte Antwort
madhan ravi
am 29 Okt. 2018
Bearbeitet: madhan ravi
am 29 Okt. 2018
r = range_calculator % calling of the function
function r = range_calculator
g=9.9;
a=0:0.05:pi/2;
v=linspace(50,100,numel(a));
for k=1:length(v)
r(k)=(v(k).^2/g).*sin(2.*a(k));
end
plot(a,r,'--r*')
grid on
title('The initial velocity is v(k)')
xticks(-0.4:0.2:1.8)
yticks(0:50:800)
xlabel('Cannon Angle')
ylabel('Range,Meters')
end
5 Kommentare
madhan ravi
am 29 Okt. 2018
Anytime , if you got the answer for your question make sure to accept the answer so that people know the question is solved
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!