i have inserted the following equation into matlab, i want values of Z for each value of w from 0.001:1000. but i keep getting a single value only. i will insert my matlab code below, i have converted the names of some values into simple a,b,c,e to make it easy for me to insert the values into matlab. ill insert some pictures what my question.
my matlab code: >> a = 1; t = 1; w = 0.001:1000; b = 10; d = 0.25; c = cos((d*pi)/2); e = w*t; z = sqrt((a.^(2)*e.^(2*d)+2*c*b*a*e.^(d)+b.^2)/(1+2*c*e.^(d)+e.^(2*d)))
z =
2.5265
>>

 採用された回答

Star Strider
Star Strider 2017 年 11 月 9 日

1 投票

You need to completely vectorise your equation, including the division:
z = sqrt((a.^(2)*e.^(2*d)+2*c*b*a*e.^(d)+b.^2)./(1+2*c*e.^(d)+e.^(2*d)));
↑ ← VECTORISE DIVISION
That should work.

1 件のコメント

Star Strider
Star Strider 2017 年 11 月 9 日
My pleasure.
Since this is homework, type:
lookfor log10
in your Command Window. Click on the result.
You could do the same for ‘plot’ (so lookfor plot). You would then see the documentation on the plot (link) function.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by