Mutual shadings with surfl
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Prabhan Purwar
am 23 Okt. 2020
Bearbeitet: Prabhan Purwar
am 23 Okt. 2020
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 Kommentare
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!