Re: Non-rectangular 3D plot



Hi Roger,

I'm trying the method you've shown,since it is the most familiar for me.
The tip on parameter representation helped! I've modified your code to work
with my case, please see below. I am wondering if I have applied my 'for
loop' properly to get x and y vectors and the z matrix. My results are not
what I am expecting, although much improved over before! Thanks again!

% Range variables
Xpts = a:1:b;
Ypts = min:1:max;
% Preallocation of matricies
m = numel(Xpts);
n = numel(Ypts);
Z = zeros(4,m,n); %3d matrix, a 4x1 vector calculated over changes in vectors:
x (size m) & y (size n)
x = zeros(m);
y = zeros(n);
[ix,iy] = meshgrid(1:m,1:n); % Use a p by q mesh of ix & iy values
% Loop to create z-matrix
for i = 1:m
x(i) = min(X4) + (ix(i)-1)*(max(X4)-min(X4))/(m-1); % a <= x <= b
for j = 1:n
y(i,j) = (iy(j)-1).*(M*x(i)+b)/(n-1); % 0 <= y <= m*x+b
Variable1(i,j) = x(i) + y(i,j);
Variable2(i,j) = x(i) - y(i,j);
[Z(:,i,j)] = FunctionMfile(Variable1(i,j),Variable2(i,j),x(i),y(i,j))
;
end
end
[x,y] % check matrix
z(i,j) = Z(1,i,j); % plot of one layer of 3d matrix only, since 'surf' only
accepts z as a 2d matrix
surf(x,y,abs(Z))
colormap hsv
colorbar

Regards,
Bookie

Roger Stafford wrote:
Hi,

[quoted text clipped - 5 lines]

Bookie
----------
In the 'surf' and 'surfc' functions it isn't necessary that the x-y domain
covered be a rectangle. It is only necessary that there be a two-parameter
representation of the desired surface in which the parameters fill a
rectangular space. In your example, you could use parameters, ix and iy
where

[ix,iy] = meshgrid(1:p,1:q); % Use a p by q mesh of ix & iy values
x = a + (ix-1)*(b-a)/(p-1); % a <= x <= b
y = (iy-1).*(m*x+b)/(q-1); % 0 <= y <= m*x+b
z = (Whatever your function of x and y is)
surf(x,y,z)

There is an example of a sphere generated by 'surf' in the function reference
to matlab. Study it to see how the parameterization works. In particular note
that what you call the "shadow" is a circle in this case.

Roger Stafford

--
Message posted via MathKB.com
http://www.mathkb.com/Uwe/Forums.aspx/matlab/200804/1

.



Relevant Pages

  • Re: Non-rectangular 3D plot
    ... Roger Stafford wrote: ... In the 'surf' and 'surfc' functions it isn't necessary that the x-y domain ... rectangular space. ... There is an example of a sphere generated by 'surf' in the function reference ...
    (comp.soft-sys.matlab)
  • Re: vectorize
    ... ellieandrogerxyzzy@xxxxxxxxxxxxxxxxxxxxxx (Roger Stafford) wrote: ... I believe your code is slow because for each pass through the loop, ... possibly a way of vectorizing the entire process. ... positive integers and all like numbers are grouped together, ...
    (comp.soft-sys.matlab)
  • Re: Terminating a while loop from keyboard and con
    ... Roger Stafford wrote: ... > In article, sgrongst ... >> criterion> ... Basically you want to quit the loop ...
    (comp.soft-sys.matlab)
  • Re: sometimes endless loop, sometimes not
    ... I'm using ASP, and an ... > Access 2003 database. ... > When i surf to my page, ... > query, only other time), my page goes into an endless loop. ...
    (microsoft.public.data.ado)
  • Re: sometimes endless loop, sometimes not
    ... after the loop, or remove the On Error Resume Next, eg. ... Make sure you're running Jet 4.0 as it has row level locking rather than ... Dan ... >>> When i surf to my page, ...
    (microsoft.public.data.ado)