plotting functions in matlab

조회 수: 8 (최근 30일)
payam abubakr
payam abubakr 2020년 5월 11일
편집: Stephen23 2020년 5월 12일
Hello, can you help with this question, please?
I want to plot a function of y(theta) = sin(theta) , but matlab gives me error i don't know why.
I have tried this so far,
function [y] = myfunction(/theta)
y = sin(/theta)
end

채택된 답변

Stephen23
Stephen23 2020년 5월 11일
function [y] = myfunction(theta) % "/" is not valid in a variable name
y = sin(theta);
end
  댓글 수: 4
Stephen23
Stephen23 2020년 5월 11일
편집: Stephen23 2020년 5월 12일
Like most programming languages, MATLAB does not have implicit multiplication of two things written next to each other: if two things are multiplied together, you need to write some multiplication operator between them.
This means your code is invalid because it is missing a multiplication operator:
cos(2 theta)?
% ^ missing!
Try this:
cos(2*theta)
"it does not allow me to plot it even with this code"
You need to learn about array and matrix operations:
y = sin(theta).*cos(2*theta);
% ^^ element-wise times
payam abubakr
payam abubakr 2020년 5월 11일
thank you! it helped me a lot.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by