Hi All,
I need mutiple values for x for a range of t, it is only keeping the last variable, What do I do?
Here is my code
for t = 0:1:100
x = (0.5exp(2*sin(t)))/(10.5*exp(2*sin(t)));
end
Thank you

 採用された回答

Torsten
Torsten 2023 年 3 月 11 日

0 投票

You mean
t = 0:1:100;
x = 0.5*exp(2*sin(t))./(10.5*exp(2*sin(t)));
plot(t,x)
(which is equal to 0.5/10.5=0.04761... because exp(2*sin(t)) cancels out) ?

3 件のコメント

Alice K
Alice K 2023 年 3 月 11 日
編集済み: Walter Roberson 2023 年 3 月 11 日
Sorry there was a typo, this is my full code
I need to plot x againts M
t = 0:1:100;
u = 1;
v = 1;
A = 0.1
for t = 0:1:100
x = (A.*exp(u.*sin(t)))/(1+A.*exp(u.*sin(t)))
end
M = (1+v.*cos(t).*A.*exp(u.*sin(t))+v.*cos(t)-1)/(1+A.*exp(u.*sin(t)));
figure
plot(M,x)
I am getting nothing on the graph.
Walter Roberson
Walter Roberson 2023 年 3 月 11 日
You should avoid using the / operator, except possibly for the case of dividing by a literal constant. The / operator is not the division operator: it is the matrix division operator, with A/B being similar to A*pinv(B) or similar to least-squares regression. Use ./ for the division operator
I would suggest to you that in the cases where you really do want to use matrix division or matrix least-squares that instead of A/B that you use (B'\A')' instead -- the use of \ emphasizes the matrix operation.
t = 0:1:100;
u = 1;
v = 1;
A = 0.1
A = 0.1000
x = (A.*exp(u.*sin(t))) ./ (1+A.*exp(u.*sin(t)))
x = 1×101
0.0909 0.1883 0.1989 0.1033 0.0448 0.0369 0.0703 0.1617 0.2119 0.1312 0.0549 0.0355 0.0552 0.1321 0.2122 0.1608 0.0698 0.0368 0.0451 0.1041 0.1995 0.1876 0.0902 0.0411 0.0389 0.0805 0.1765 0.2065 0.1159 0.0490
M = (1+v.*cos(t).*A.*exp(u.*sin(t))+v.*cos(t)-1) ./ (1+A.*exp(u.*sin(t)));
figure
plot(M,x)
Alice K
Alice K 2023 年 3 月 11 日
It Works,
Amazing, Thank you

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

製品

リリース

R2022b

タグ

質問済み:

2023 年 3 月 11 日

コメント済み:

2023 年 3 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by