Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with plotting a function in Matlab

Status
Not open for further replies.

AdvaRes

Advanced Member level 4
Joined
Feb 14, 2008
Messages
1,163
Helped
113
Reputation
220
Reaction score
51
Trophy points
1,328
Location
At home
Activity points
7,442
Hi guys,

I'm trying to plot a function. When I compile matlab shows no error but I get no curve.

Here is the code:

Vc=linspace(0,1.2)
R3=1./(5*Vc)
R7=9
RL=(R3*R7)/(R3+R7)
D=RL*9
F=1/(10*D)
plot(Vc,F)

Where is the problem ?
 

Matlab for plotting

Hi AdvaRes,

Replace "/" by "./" in the 4th and 6th lines.
Regards

Z
 

Matlab for plotting

Hi zorro,

Actually I did it but I get error:
Matrix dimensions must agree
 

Matlab for plotting

Strange.
I run the code with the changes above and it works.
Which line gives the error?
 

    AdvaRes

    Points: 2
    Helpful Answer Positive Rating
Matlab for plotting

Its line 4.
Did you really plot a curve for F ?
What version of Matlab are you using ?
 

Re: Matlab for plotting

Hi AdvaRes,
AdvaRes said:
Its line 4.
Please check the results of these commands:
>> size(R3*R7) % should be 1 100
>> size(R3+R7) % should be 1 100
>> size((R3*R7)./(R3+R7)) % should be 1 100
Did you really plot a curve for F ?
Yes, I do.
What version of Matlab are you using ?
MATLAB Version 7.1.0.246 (R14) Service Pack 3.

Regards

Z
 

    AdvaRes

    Points: 2
    Helpful Answer Positive Rating
Re: Matlab for plotting

I just did what zorro suggested...
Code:
Vc=linspace(0,1.2)
R3=1./(5*Vc)
R7=9
RL=(R3*R7)./(R3+R7)
D=RL*9
F=1./(10*D)
plot(Vc,F)
and here is the picture:
 

    AdvaRes

    Points: 2
    Helpful Answer Positive Rating
Re: Matlab for plotting

make sure you don't have any previus data in your memory with the same name but different size,
clear all;
and try
 

    AdvaRes

    Points: 2
    Helpful Answer Positive Rating
Re: Matlab for plotting

Thank you guys !
I couldn't resolve it but I could get a plot only when I compiled it on another PC.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top