How to use previous points calculated from a function.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Heraldo Tello
am 24 Okt. 2020
Beantwortet: Heraldo Tello
am 26 Okt. 2020
Hello I have the following function
d=abs(B32 + A32*[X;Y]);sqrt(A32(1,1)^2+A32(1,2)^2);
the answer (d) changes based on the row matlab is on.
I have no problem calculating (d) based on the row.
What I want to do is use an equation R = d2*(t2-t1)/(d1-d2)
What I want to do is d2 to equal the current (d) that is being calculated.
I want d1 to equal the previous answer for (d).
I want the first d1 that is used to = 0 then the next d1 to equal (d) and so forth.
Is this possible.
Any help is greatly appreciated.
2 Kommentare
Mitchell Thurston
am 24 Okt. 2020
If I get the jist of what you're saying:
d1 = 0;
d2 = abs(B32 + A32*[X;Y]);
% it also looks like after the semicolon this is just being saved to "ans"
% .
% .
% .
% This is within some kind of loop
d2 = abs(B32 + A32*[X;Y]);
R = d2*(t2-t1)/(d1-d2);
d1 = d2;
Is this about what your asking for?
Akzeptierte Antwort
Weitere Antworten (1)
KSSV
am 24 Okt. 2020
You can solve the given equation:
R = d2*(t2-t1)/(d1-d2) ;
for d2 and solve it to get d2. We have d2 as:
d2 = R*d1/(R-t1+t2) ;
I assume that the (t2-t1) will be nothing but t(i+1)-t(i) .. if you use a loop; so this will be a time step and mostly will remain constant. Let it be dt. So the equation for d2 becomes:
d2 = R*d1/(R+dt)
Now you need not use a loop..get the distance d1 and then find d2.
d=abs(B32 + A32*[X;Y]);sqrt(A32(:,1).^2+A32(:,2).^2); %
The above formula should give you all d's at once. It might throw some error, in that case you need to give us more details about [X Y] and A32. Once d is obtained, use the equation for d2 and get d2.
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!