Shane Yost
Shane Yost

Reputation: 231

Cannot plot in Matlab. It says my matrix is empty. Weird?

Doing some simple plotting and I cannot seem to figure out why I can't plot my data. I troubleshooted it first by checking to see if I had any data in my arrays first. I did not!! I'm completely lost on how to fix this.

Image

I also tried creating a script to see if maybe it solved the issue instead of using the command window. I still get the same error.

Code:

t=0:1e-6:((2e-3-1e-6)-1);
vm=sin(2*pi*1e3*t);
vc=sin(2*pi*20e3*t);
vdsb=vc.*vm;
plot(t,vdsb,'b')

Upvotes: 1

Views: 96

Answers (1)

Steve
Steve

Reputation: 4097

You probably don't want that last -1 in your code setting up t. Try changing t to:

t=0:1e-6:((2e-3-1e-6));

Or, if you really want it negative, you need to change the step size to negative:

t=0:-1e-6:((2e-3-1e-6)-1);

Otherwise, t is defined from 0:psotiveStep:negativeNumber and so it is empty.

Upvotes: 4

Related Questions