Can someone tell how I should code this equation for plot

1 view (last 30 days)
x(t)=0.8cos(14t) this is my equation and i'm unable to plot this equation. It show me a error "Array indices must be positive integers or logical values."

Accepted Answer

Star Strider
Star Strider on 6 Oct 2021
That would work (with multiplication operators) in the Symbolic Math Toolbox —
syms t
x(t) = 
fplot(x, [-2*pi 2*pi])
It would need to be coded as an anonymous function to use it numerically —
x = @(t) 0.8*cos(14*t);
t = linspace(-2*pi, 2*pi, 500);
plot(t, x(t))
See the documentation section on Anonymous Functions for details.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by