How to get z for different x

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 commentaires

Thomas
Thomas le 18 Déc 2012
what error are you getting? what answer do you expect?
Atom
Atom le 18 Déc 2012
Modifié(e) : Atom le 18 Déc 2012
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).

Connectez-vous pour commenter.

 Réponse acceptée

Wayne King
Wayne King le 18 Déc 2012
Modifié(e) : Wayne King le 18 Déc 2012

0 votes

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)

Plus de réponses (2)

Thomas
Thomas le 18 Déc 2012

0 votes

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 le 18 Déc 2012

0 votes

Presumably you want to use ./ instead of /, just like you are using .* instead of *

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by