help-octave
[Top][All Lists]
Advanced

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

Re: plotting mulitple variables vs y


From: Ben Abbott
Subject: Re: plotting mulitple variables vs y
Date: Tue, 23 Apr 2013 13:25:43 -0400

On Apr 23, 2013, at 12:01 PM, Kirk wrote:

> I am trying to plot 2 variables in an equation against the y value but it 
> does not seem to be doing that for me in Octave.
> my small example I came up with is this code below
> 
> z=0.1;
> for x1 = 1:0.5:2
> for x2 = 0:0.1:1.5
> 
> y = sqrt(x1+x2^2)+z;
> hold on;
> plot(y,x2);
> end
> hold off;
> end
> 
> 
> I don't know if there is an easier way or if my syntax is wrong but i get a 
> plot but with no value points or a line connecting them.
> Kirk

Does this do what you want?

z = 0.1;
x1 = 1:0.5:2;
x2 = 0:0.1:1.5;
[x1, x2] = meshgrid (x1, x2);
y = sqrt (x1 + x2.^2) + z;
mesh (x1, x2, y)

Ben



reply via email to

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