Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Plotting vectors

Subject: Plotting vectors

From: Yan Rosh

Date: 18 Dec, 2008 10:46:02

Message: 1 of 4

I know this might be a silly question, but i'm really new to Matlab, and still sort of struggling with it, anyways my problem is as such:

I have an equation looking like this:
y = exp(i*(w*t - k*z));
w is a known vector and k is another vector of the same size, t is my variable, z is a constant (its the solution to the wave equation). Whenever I try to plot this I get this error message: "Matrix dimensions must agree."
How can I plot this? I tried working with a 'for' loop to and make it a superposition of 'cos' function but I got a funny result, is there an easier way to work with this?

Thanks in advance,
Yan Rosh

Subject: Plotting vectors

From: David

Date: 18 Dec, 2008 11:08:02

Message: 2 of 4

"Yan Rosh" <yan_rosh@yahoo.com> wrote in message <gid9la$jh2$1@fred.mathworks.com>...
> I know this might be a silly question, but i'm really new to Matlab, and still sort of struggling with it, anyways my problem is as such:
>
> I have an equation looking like this:
> y = exp(i*(w*t - k*z));
> w is a known vector and k is another vector of the same size, t is my variable, z is a constant (its the solution to the wave equation). Whenever I try to plot this I get this error message: "Matrix dimensions must agree."
> How can I plot this? I tried working with a 'for' loop to and make it a superposition of 'cos' function but I got a funny result, is there an easier way to work with this?
>
> Thanks in advance,
> Yan Rosh

learn to use the debugger. tell it to stop on error and then examine the sizes and contents of w,t,k,z... try evaluating the pieces of the equation one at a time to see where the error is at that point.

Subject: Plotting vectors

From: Yan Rosh

Date: 18 Dec, 2008 12:01:05

Message: 3 of 4

> learn to use the debugger. tell it to stop on error and then examine the sizes and contents of w,t,k,z... try evaluating the pieces of the equation one at a time to see where the error is at that point.

Thanks, ill try that.

Yan Rosh

Subject: Plotting vectors

From: Adam

Date: 18 Dec, 2008 14:10:21

Message: 4 of 4

"Yan Rosh" <yan_rosh@yahoo.com> wrote in message <gide21$86$1@fred.mathworks.com>...
> > learn to use the debugger. tell it to stop on error and then examine the sizes and contents of w,t,k,z... try evaluating the pieces of the equation one at a time to see where the error is at that point.
>
> Thanks, ill try that.
>
> Yan Rosh

In matlab * ^ / are all matrix operations. You want to do element by element so the syntax is .* .^ ./

~Adam

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us