help-octave
[Top][All Lists]
Advanced

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

Re: problem with mesh-plot


From: Juan Pablo Carbajal
Subject: Re: problem with mesh-plot
Date: Thu, 21 Feb 2013 14:25:26 +0100

On Thu, Feb 21, 2013 at 1:55 PM, Hugo Coolens <address@hidden> wrote:
> I'm trying to make a mesh-plot as can be seen in the code below:
> clear
> [x, y] = ndgrid (0.1:0.1:1);
> tau11=x(:);
> tau22=y(:);
> #tau12=0
> sigma=tau11+tau22;
> p=tau11.*tau22;
> A=sqrt(p.^2+2*p.*sigma.^2)-p;
> hjwmax=sqrt((1+A./p)./((1-A./sigma.^2).^2+A./p));
> [xmax, ixmax]=max(hjwmax);
> disp('de max. amplification equal to: '),disp(xmax)
> disp('for this max. amplification tau11 (x-as): '), disp(tau11(ixmax))
> disp('for thi smax. amplification tau22 (y-as): '), disp(tau22(ixmax))
> length(tau11)
> length(tau22)
> length(hjwmax)
> mesh(tau11,tau22,hjwmax)
> #plot3(tau11,tau22,hjwmax)
>
> I get the following error-message which puzzles me as x, y and zo do have
> the same length:
> error: surface: rows (z) must be the same as length (y) and columns (z) must
> be the same as length (x)
> error: called from:
> error:   /usr/share/octave/3.2.4/m/plot/surface.m at line 111, column 9
> error:   /usr/share/octave/3.2.4/m/plot/surface.m at line 51, column 5
> error:   /usr/share/octave/3.2.4/m/plot/mesh.m at line 37, column 7
> error:   /home/coolens/palp2tau12zero.m at line 14, column 1
> octave:1>
> gnuplot> plot "-";
>               ^
>          line 2: warning: Skipping data file with no valid points
>
> what's going wrong here?
> thanks in advance
> hugo
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>

Hi Hugo
If you do
> whos tau11 tau22 hjwmax
yousee that you have made your meshes a single column vector. Now if you do
> help mesh
you can read that it expects arguments to have the meshgrid format (matrices).

Your code works if you remove the lines where you flat the matrices

[tau11, tau22] = ndgrid (0.1:0.1:1);
sigma = tau11 + tau22;
p = tau11 .* tau22;
A = sqrt (p.^2 + 2*p.*sigma.^2) - p;
hjwmax = sqrt ((1 + A./p)./((1-A./sigma.^2).^2 + A./p));
mesh (tau11, tau22, hjwmax)


reply via email to

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