I wrote a script with a function
ex: function [DV] = deltaV(debris1, debris2, t1,t2,t1_0,t2_0,rE,mu,J2)
I have to plot the function with an increasing t2 or an increasing debris2(3) (debris1 and debris2 are vectors)
how can I do that?

 Akzeptierte Antwort

Jan
Jan am 26 Jun. 2021

0 Stimmen

t2 = linspace(0, 10, 100);
DV = zeros(size(t2));
for k = 1:numel(t2)
DV(k) = deltaV(debris1, debris2, t1, t2(k), t1_0, t2_0, rE, mu, J2);
end
plot(t2, DV);

2 Kommentare

Giorgia Di Dio
Giorgia Di Dio am 26 Jun. 2021
Thank you
It works for t2 even though I have to use it for small numbers, but I can't make it work for debris2(3).
Do I have to use it in the same way even if debris2 is a vector?
debris2 = rand(1, 3);
DV = zeros(1, 100);
for k = 1:100
debris2(3) = rand;
DV(k) = deltaV(debris1, debris2, t1, t2, t1_0, t2_0, rE, mu, J2);
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 26 Jun. 2021

Kommentiert:

Jan
am 28 Jun. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by