フィルターのクリア

How to get z for different x

3 ビュー (過去 30 日間)
Atom
Atom 2012 年 12 月 18 日
x = [-2:0.1:2];
z=x.*(1-x).*(2-x).*(4-x)/((6-x)-(1-x).*(x-7));
I am getting error. Please correct my problem.
  2 件のコメント
Thomas
Thomas 2012 年 12 月 18 日
what error are you getting? what answer do you expect?
Atom
Atom 2012 年 12 月 18 日
編集済み: Atom 2012 年 12 月 18 日
There are 41 values of x and for each x I need one z. I am not getting this. I am getting only one value of z (=-2.1203).

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

採用された回答

Wayne King
Wayne King 2012 年 12 月 18 日
編集済み: Wayne King 2012 年 12 月 18 日
x = [-2:0.1:2];
z = x.*(1-x).*(2-x)./((6-x).*(x-7));
You just forgot a ./
Now you should have a vector
x = [-2:0.1:2];
z = x.*(1-x).*(2-x)./((6-x).*(x-7));
plot(x,z)
  1 件のコメント
Atom
Atom 2012 年 12 月 18 日
Yes. Thanking you.

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

その他の回答 (2 件)

Thomas
Thomas 2012 年 12 月 18 日
x = [-2:0.1:2];
z=x.*(1-x).*(2-x).*(4-x)./((6-x)-(1-x).*(x-7))
You missed the . before the division to do element by element division

Daniel Shub
Daniel Shub 2012 年 12 月 18 日
Presumably you want to use ./ instead of /, just like you are using .* instead of *

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by