フィルターのクリア

How to use previous points calculated from a function.

4 ビュー (過去 30 日間)
Heraldo Tello
Heraldo Tello 2020 年 10 月 24 日
回答済み: Heraldo Tello 2020 年 10 月 26 日
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 件のコメント
Mitchell Thurston
Mitchell Thurston 2020 年 10 月 24 日
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?
Heraldo Tello
Heraldo Tello 2020 年 10 月 24 日
when I'm calculating the R = d2*(t2-t1)/(d1-d2)
I want d2 = d = abs(B32 + A32*[X;Y]);sqrt(A32(1,1)^2+A32(1,2)^2);
another way to describe this is R = (current (d))*(t2-t1)/[(previous (d) that was calculated) - (current (d) that is calculated)]
d1 = the previous d that was calculated before the current (d)
however, when running this (loop I'm assuming), if d2 = the very first d that was calculated,
there is no previous (d) for d1 to take so I want d1 to initially be = 0 for this case. the next d1 will equal be the previous (d)

サインインしてコメントする。

採用された回答

Heraldo Tello
Heraldo Tello 2020 年 10 月 26 日
% Plotting the TestPoints on the graph
for i = 1:size(TestPoints,1)
X=TestPoints(i,2);
Y=TestPoints(i,3);
Delta1=log(P1)-0.5*mu1*inv(Sw)*mu1'+mu1*inv(Sw)*[X;Y];
Delta2=log(P2)-0.5*mu2*inv(Sw)*mu2'+mu2*inv(Sw)*[X;Y];
Delta3=log(P3)-0.5*mu3*inv(Sw)*mu3'+mu3*inv(Sw)*[X;Y];
pause(1)
clc
% The first initial d1 = 0 because there is no previous distance. It's the
% first one. The next d1 will have the previous value of d2.
try
d1;
catch
d1=0;
end
% The first initial t1 = 0 because there is no previous time. It's the
% first one. The next t1 will have the previous value of t2.
try
t1;
catch
t1=0;
end
%
d2=abs(B32 + A32*[X;Y]);sqrt(A32(1,1)^2+A32(1,2)^2); % Distance to the LDA Boundary that separates aged and replace
t2=TestPoints(i,1); %time in seconds for the particular datapoint
%
%Calculating the Remaining Useful Life
RUL = d2*(t2-t1)/(d1-d2); % Units are in seconds
RUL_days=RUL/86400; % Units are in days
d1=d2;
t1=t2;
pause(1)
end

その他の回答 (1 件)

KSSV
KSSV 2020 年 10 月 24 日
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.
  1 件のコメント
Heraldo Tello
Heraldo Tello 2020 年 10 月 24 日
Sorry should have been more specific on the R formula. I am trying to solve for R. In order to do this I must know the current value of (d) and the past value of (d). I know what my t values are at each given point.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

製品


リリース

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by