[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Function of vector with meshgrid and surf
From: |
Sebastian Schöps |
Subject: |
Re: Function of vector with meshgrid and surf |
Date: |
Wed, 11 Nov 2015 15:26:39 -0800 (PST) |
karl wrote
> I have a small problem with the syntax.
> ...
> How do I have to modify the line "Z=frame([X,Y])" that the surf command
> works and gives the surface?
X and Y are matrices (in your case 11x11) and [X,Y] is even 11x(2*11). Your
functions expects vectors and thus it does not work properly. You either
have to modify "frame" to allow matrix input or you have to loop over the
entries. Here are three possibilities:
function karl
x1=0:0.1:1;
[X,Y]=meshgrid(x1,x1);
Z=frame_modified(X,Y);
figure;
surf(X,Y,Z);
for i=1:size(Z,1)
Z(i,:)=frame([X(i,:); Y(i,:)]);
end
figure;
surf(X,Y,Z);
for i=1:size(Z,1)
for j=1:size(Z,1)
Z(i,j)=frame([X(i,j); Y(i,j)]);
end
end
figure;
surf(X,Y,Z);
end
function fr = frame_modified (x,y)
fr=x+y;
endfunction
function fr = frame (x)
fr=x(1,:)+x(2,:);
endfunction
--
View this message in context:
http://octave.1599824.n4.nabble.com/Function-of-vector-with-meshgrid-and-surf-tp4673436p4673444.html
Sent from the Octave - General mailing list archive at Nabble.com.