help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: displaying an image


From: Nicholas Jankowski
Subject: Re: displaying an image
Date: Sat, 12 Sep 2015 16:28:52 -0400

On Sat, Sep 12, 2015 at 4:20 PM, lana frankle <address@hidden> wrote:


On Sat, Sep 12, 2015 at 1:00 PM, Nicholas Jankowski <address@hidden> wrote:
On Sat, Sep 12, 2015 at 2:56 PM, lana frankle <address@hidden> wrote:


On Sat, Sep 12, 2015 at 12:07 AM, Andy Buckle <address@hidden> wrote:


On 12 September 2015 at 06:02, lana frankle <address@hidden> wrote:
Octave is giving me the following error while I'm trying to do 2-D plotting:

>> y=((x+5).^2)/(4+3*x.^2)
y =  1.5625
>> figure plot(X,Y)
error: figure: N must be figure handle or figure number
error: called from
    figure at line 67 column 7

I'm not sure what it means.  Where do I put the "N"?

you are sending plot as an argument to figure. you probably want to put them on separate lines

figure
plot(X,Y)

The error is coming from figure, so in general you should look at the help for the figure function. like this

help figure

it explains that calling figure with an argument N is useful when you have multiple figures open and you want to switch back to one created earlier.

--
/* andy buckle */

now it's telling me "error: 'x' undefined near line 1 column 5".
I'm not sure the code I'm entering prior to the line where I define y is exactly the same as it was yesterday (I didn't save the code in the command window) right now it's 
if x>=3 and x=<5: 


well, hard to guess without seeing the actual code you're using. Note you can use a text editor or the built in editor to write your commands in a script file, (one command per line just like you'd type on the command line). then save it as a filename.m file, and you can run the script by typing 'filename'.  this allows you to edit code you run more than once, get into programming, etc.

Assuming the code above is like what you're running, you're defining x and y but trying to plot X and Y.  Octave is case sensitive so those are not the same.

> right now it's 
> if x>=3 and x=<5:

I'm not sure what you mean by this as it has nothing to do with the code listed above.

It's not just the case-sensitive thing though because that error message shows before I try to plot.  x>=-3 and x=<5 was given in the problem I'm trying to work from the book "MATLAB: An Introduction with Applications".  The error shows right after I define y.  My code is:

if x>=-3 and x=<5:
y=((x+5).^2)/(4+3*x.^2)
error: 'x' undefined near line 1 column 5
#and once that's resolved, I'll want to do
figure
plot(X,Y)

(will I need a semi-colon after figure?)

you never need a semi-colon anywhere. a semi-colon just tells Octave not to display the result of the calculation on that line.


why do you have a colon after the x=<5 ?


I'm not certain what you're trying to do here with the if statement. my guess is you're trying to take a problem statement from the book and apply it too literally to the code.

if is a conditional statement. it can not define a range for x.

if the problem is asking you to plot y = ((x+5).^2)/(4+3*x.^2) if x is between -3 and 5, then you need to first define x to have values between -3 and 5. only after you've assigned values to x can you run the next line defining corresponding values for y.

You should refer to the documentation for the basic syntax used by Octave. it will help with this and a number of other questions that you've asked before.

finally, you're plot(X,Y) line can't use capital X and Y.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]