Why do i need to use .^ notation ?

조회 수: 4 (최근 30일)
Yash Shil Balgobin
Yash Shil Balgobin 2021년 4월 3일
댓글: Yash Shil Balgobin 2021년 4월 3일
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

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 4월 3일
편집: KALYAN ACHARJYA 2021년 4월 3일
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
Yash Shil Balgobin
Yash Shil Balgobin 2021년 4월 3일
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 2021년 4월 3일
@KALYAN ACHARJYA Thank you so much for the edit. It all makes sense now.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by