Hello, I am trying to solve an equation involving two vectors.

1 回表示 (過去 30 日間)
Charles Naegele
Charles Naegele 2018 年 5 月 18 日
コメント済み: Charles Naegele 2018 年 5 月 18 日
I have vector P (3000x1) and T (1x3000). I plotted P vs. T just fine. Now, I have to solve an equation, tau = -T/ln(P/P(0)) I tried this, but it returns 3000 numbers:
if true
% code
end
for i = 1:3000
tau(i) = -T(i)/log(P(i)/P(1));
end
  5 件のコメント
Charles Naegele
Charles Naegele 2018 年 5 月 18 日
Also, does the indexing for 'i' make sense considering my vectors contain 3000 values, or should i = 1:3001?
Charles Naegele
Charles Naegele 2018 年 5 月 18 日
I think the accepted answer works for my application. Thank you for your time.

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

採用された回答

Star Strider
Star Strider 2018 年 5 月 18 日
No need for the loop. Just use the mrdivide,/ (link) function:
tau = -T / log(P')/P(1);
Note the transposition (') operator to create a row vector from ‘P’. That will give you a single value for your ‘tau’ parameter.
  2 件のコメント
Charles Naegele
Charles Naegele 2018 年 5 月 18 日
Thank you!
Star Strider
Star Strider 2018 年 5 月 18 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by