plotting functions in matlab
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
payam abubakr
am 11 Mai 2020
Bearbeitet: Stephen23
am 12 Mai 2020
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
0 Kommentare
Akzeptierte Antwort
Stephen23
am 11 Mai 2020
function [y] = myfunction(theta) % "/" is not valid in a variable name
y = sin(theta);
end
4 Kommentare
Stephen23
am 11 Mai 2020
Bearbeitet: Stephen23
am 12 Mai 2020
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!