Why do i need to use .^ notation ?

4 vues (au cours des 30 derniers jours)
Yash Shil Balgobin
Yash Shil Balgobin le 3 Avr 2021
Why do i need to use the .^ notation ? Is there any other way around it ?
% This is my function.
function y = PBTask4P1_f(x)
y = 4.2*x.^4-5*x.^3-7*x;
plot(x,y);
xlabel('INPUT X')
ylabel('OUTPUT Y')
end

Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 3 Avr 2021
Modifié(e) : KALYAN ACHARJYA le 3 Avr 2021
It's based on equation. .^ represent the element wise to the power of any array/vector.
See the example
a =
1 2 3 4 5 6
>> a.^2
ans =
1 4 9 16 25 36
Whereas a^2=a*a (Matrix Multiplication)
  2 commentaires
Yash Shil Balgobin
Yash Shil Balgobin le 3 Avr 2021
But the above equation is not an array, is it ? If i remove the dots for y = 4.2*x^4-5*x^3-7*x;, the function fails.
Yash Shil Balgobin
Yash Shil Balgobin le 3 Avr 2021
@KALYAN ACHARJYA Thank you so much for the edit. It all makes sense now.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by