Mutual shadings with surfl
조회 수: 1 (최근 30일)
이전 댓글 표시
Does anyone know how to combine/merge two surfaces to be used with the function surfl?
I am trying to study mutual shadings using the function surfl. If I plot only one surface, it is quite easy. For instance, by using the following code it is possible to study/identify the mutual shadings created by the light on the function ripples [1]:
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
s = [-45 30];
k = [.65 .4 .3 10];
sl = surfl(X,Y,Z,s,k);
Nevertheless, I still did not figure out how to do it when there are two surfaces. For instance, in the following code I have two surfaces but surfl works only on one surface, the upper one (I have omitted s and k, in the first surfl(X,Y,Z) to see if by specifying those only one time was ok). It looks that the parameters s and k are only related to a single surface. Is there a way to set the ligth that works for both surfaces? Thanks in advance for any suggestion.
s = [0 15];
k = [1 .3 .3 0];
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = zeros(size(X));
surfl(X,Y,Z)
hold on
[X,Y] = meshgrid(1:0.5:10,1:20);
Z(:,:)=1;
surfl(X,Y,Z,s,k)
References
댓글 수: 0
답변 (2개)
Prabhan Purwar
2020년 10월 23일
편집: Prabhan Purwar
2020년 10월 23일
Hi,
Following code illustrates the surfl implementation upon multiple surfaces.
1) First implementation explains surfl implementation taking each surface as separate surfaces.
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
s = [-45 30];
k = [.65 .4 .3 10];
surfl(X,Y,Z,s,k); %Surface
surfl(X,Y,Z,s,k)
hold on
surfl(X,Y,20+Z,s,k)
hold off
2) Second implementation explains surfl implementation after combining two surfaces as a single surface.
buffer = nan*ones(1,size(X,2));
X3 =[X;buffer;X];
Y3 =[Y;buffer;Y];
Z3 =[Z;buffer;20+Z];
surfl(X3,Y3,Z3,s,k)
Hope it helps!!
Thanks
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!