This is amy code it is not working why?

x=[1 4 5 7.5 14 21 23 32]
v=x.^(2) * exp.(x) + x * (( x + log(x)).^(1/2))

1 commentaire

Rik
Rik le 13 Sep 2018

Today I formatted your code, next time, use the {}Code button. See here for a GIF showing how to do it.

Réponses (2)

madhan ravi
madhan ravi le 13 Sep 2018
Modifié(e) : madhan ravi le 13 Sep 2018
x=[1 4 5 7.5 14 21 23 32]
v=x.^(2).*exp(x)+x.*((x+log(x)).^(1/2))
v=vpa(v)

3 commentaires

Rik
Rik le 13 Sep 2018
The explanation for answer is this: your code uses matrix multiplications. If you want element-wise operation, you should use the dot-version. This is for * / and ^.
madhan ravi
madhan ravi le 13 Sep 2018
Modifié(e) : madhan ravi le 13 Sep 2018
Exactly as Rik Wisselink mentioned element wise operation should be used since your x is a vector
madhan ravi
madhan ravi le 13 Sep 2018
If it solved the problem please accept the answer.
Guillaume
Guillaume le 13 Sep 2018
Modifié(e) : Guillaume le 13 Sep 2018
The problem is the dot after exp that shouldn't be there and the missing dots before the two *
% v----------- problem was here
v=x.^(2) .* exp(x) + x .* (( x + log(x)).^(1/2))
% ^------------^------ and here

Cette question est clôturée.

Clôturé :

le 20 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by