Hello
Below is a section of code that I am working on. The basic idea is to create a surface 30mm square that has a surface that varies according to two sinewave functions. However, my code runs into issue in the Z assignment of the loop. Any help would be appreciated. Also if you have a more compact way
LengthX = 30; % X Length of sample in mm
LengthY = 30; % Y Length of sample in mm
X_k =2; % Number of Periods along X
Y_k =1; % Number of Periods along Y
DegX = pi .* X_k; %Degrees in X
DegY = pi .* Y_k; %Degrees in y
StepSize = 0.05; % Evenly Spaced X,Y gridpoints
x=0:StepSize:LengthX; y= 0:StepSize:LengthY; NumXStep = DegX / length(x);NumYStep = DegY / length(y);Z = zeros(length(x), length(y));for Counter = 0:1:length(x) for Counter2 = 0:1:length(y)% Z =(sin(x)+sin(y)),(-2*pi:0.1:2*pi),(-2*pi:0.1:2*pi);
Z[Counter, Counter2] = sin(NumXStep*Counter)+sin(NumYStep*Counter) endendsurf(x,y,Z)
Best Answer