plotting when variables are conditional

조회 수: 1 (최근 30일)
Prince Igweze
Prince Igweze 2019년 11월 7일
댓글: Walter Roberson 2019년 11월 7일
t = logspace(-3,13,100)
for j = 1:100
q = inv((At * Cdi * A) + (t(j) * Ht * H)) * At * Cdi * do
c1(j) = transpose((A * q) - do) * Cdi * ((A * q) - do)
end
m = inv((At * Cdi * A) + (t("C1 = N") * Ht * H)) * At * Cdi * do
depth = 1:50
plot(m,depth)
I want to plot the solution m againt depth
but for the the value of t when C1 is closest to N (i.e 20), and this value changes for each RUN
i believe an if-statement might help me achieve this, pls help
thanks
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 11월 7일
It looks unlikely to me that c1 will happen to be bit-for-bit identical to any integers.
Will you be wanting to find the index at which C1 is closest to N? Would you be wanting to find the last index at which C1 does not exceed N? The first index at which C1 is at least as high as N ? Do you want to interpolate the index at which c1 exactly equals N, and use that to interpolate a the corresponding t value?
Prince Igweze
Prince Igweze 2019년 11월 7일
yea, ill like to use the value at which C1 is closest to N, and use the corresponding t value

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2019년 11월 7일
[~, idx] = min(abs(c1 - N));
t(idx)
  댓글 수: 2
Prince Igweze
Prince Igweze 2019년 11월 7일
thanks but how do i implement this in the plot
Walter Roberson
Walter Roberson 2019년 11월 7일
[~, idx] = min(abs(c1 - N));
m = inv((At * Cdi * A) + (t(idx) * Ht * H)) * At * Cdi * do;
It seems unlikely to me that you want depth to be your y axes. It seems more likely that you would want
plot(depth, m)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by