English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i need to plot:
y(t) = e^(t/2) * cos(2t) , 0
so i typed:
t=0:0.001:01;
y=exp(t/2)*cos(2t);

but it gives an error for the second line.
can i know how i can correctly enter the function into matlab?

2007-09-06 07:49:32 · 4 answers · asked by sh 1 in Science & Mathematics Engineering

4 answers

When you create "exp(t/2)", since t is a vector, that expression is a vector.

When you create cos(2t), since t is a vector, that expression is a vector.

You cannot simply multiply vectors in Matlab. You have to tell it to do component multiplication, that is, multiply the first element of each vector, then multiply the second element of each vector, etc., to create a new vector (y).

To do this, you must put a dot "." before the multiplication sign. It should look like this:

y=exp(t/2).*cos(2t);

2007-09-06 07:58:32 · answer #1 · answered by lithiumdeuteride 7 · 1 1

Since MATLAB allows vectors and matrices to be multiplied two different ways (1. matrix multiplication, as in linear algrebra or 2. element-by-element), you need to specify the correct multiplication. Try this:

t = 0:0.001:01;
y = exp(t/2) .* cos(2*t);
plot(t,y)

See the 'help' function for more information:

help times

versus

help mtimes

2007-09-08 06:56:12 · answer #2 · answered by Predictor 3 · 0 0

Join free course, you will get all answers...

https://iversity.org/courses/modelling-and-simulation-using-matlab?r=888a2

2013-11-21 04:45:16 · answer #3 · answered by ? 1 · 0 0

t=0:0.001:01;
y=exp(t/.2)*cos(2*t);
plot(y,t);

2007-09-06 14:52:37 · answer #4 · answered by Anonymous · 0 1

fedest.com, questions and answers