Sorry to bother people, but I'm short on time and an utter novice when it comes to programming.
The aim of my code is to produce a series of surfaces on a single plot. All dimensions of which can be changed by user controlled variables (hopefully I'll attach this to a GUI later).
I initially attempted to produces from raw data in the "F2", "K2" and "T" matrices. However, I couldn't resolve the data into a form that the mesh command would accept.
To solve this I produced the "newarray" array. Unfortunately this meant that all of the points were joined as a single surface rather than a series of individual surfaces.
I have therefore attempted to separate the "newarray" array into slices in "newarray2". However, mesh command now complains that "Z must be a matrix not a vector or scalar."
Even if this process were to work I'm not entirely sure how I could convince matlabe to plot each new surface as it is created before it is overwritten in "newarray2." I'm sure I've overcomplicated the issue, but am struggling to look at the problem from a new angle.
Can anyone help me to either fix this code or tackle it from a new angle?
My code (to date) is included below. As it is it is plotting the points that should be used in a single surface currently contained in "newarray2". As setup atm "newarray" contains 3 surfaces. (NB. to run the program you have to type 1 and then enter, it's like my on switch).
Thank you in advance to anyone who has the time or inclination to help.
Rob
while 1
exit = input ('push enter to exit')
if isempty (exit)
break
end
clear arrayF
clear arrayK
clear arrayF2
clear arrayK2
clear arrayW
clear arrayL
clear newarray
clear newarray2
subplot(1,1,1);clf
subplot(1,1,1);title('dimentions')
subplot(1,1,1);xlabel('Frequency [KHz]')
subplot(1,1,1);ylabel('Spring constant [N/m]')
subplot(1,1,1);zlabel('Thickness')
hold on
% D = density
D = 3100;
%Youngs Modulus
E = 2.9*10^11;
T = 200*10^-9;
min1 = 1;
min2 = 1;
min3 = 1;
step1 = 1;
step2 = 1;
step3 = 1;
Scale1 = -6;
Scale2 = -6;
Scale3 = -9;
max1 = 3;
max2 = 3;
max3 = 3;
f1 = 0;
% 200;
f2 = 10^20;
% 3500;
k1 = 0;
k2 = 90;
% 30;
arrayF = zeros (((max1-min1)/step1):((max2-min2)/step2):((max3-min3)/step3));
arrayF2 = zeros (((max1-min1)/step1):((max2-min2)/step2):((max3-min3)/step3));
arrayK = zeros (((max1-min1)/step1):((max2-min2)/step2):((max3-min3)/step3));
arrayK2 = zeros (((max1-min1)/step1):((max2-min2)/step2):((max3-min3)/step3));
arrayT = zeros (((max1-min1)/step1):((max2-min2)/step2):((max3-min3)/step3));
arrayL = zeros (((max1-min1)/step1):((max2-min2)/step2):((max3-min3)/step3));
arrayW = zeros (((max1-min1)/step1):((max2-min2)/step2):((max3-min3)/step3));
arrayM = zeros (((max1-min1)/step1):((max2-min2)/step2):((max3-min3)/step3));
for i = min1:step1:max1
for j = min2:step2:max2
for k = min3:step3:max3
arrayK(i,j,k) = (3*E*((j*10^Scale2)*((k*10^Scale3)^3)/12))/((i*10^Scale1)^3);
arrayM(i,j,k) = D*(i*10^Scale1)*(j*10^Scale2)*(k*10^Scale3);
arrayF(i,j,k) = (((1/(2*(pi)))*(sqrt((arrayK(i,j,k))/(0.24*(arrayM(i,j,k))))))/1000);
if (((arrayK(i,j,k))<k1) || ((arrayK(i,j,k))>k2))
arrayK2(i,j,k) = 0;
else
arrayK2(i,j,k) = (arrayK(i,j,k));
end
if (((arrayF(i,j,k))<f1) || ((arrayF(i,j,k))>f2))
arrayF2(i,j,k) = 0;
else
arrayF2(i,j,k) = (arrayF(i,j,k));
end
end
end
end
q=1;
m=1;
for i = min1:step1:max1
for k = min3:step3:max3
for j = min2:step2:max2
if (((arrayF2(i,j,k))>0) && ((arrayK2(i,j,k))>0))
x = (arrayF2(i,j,k));
y = (arrayK2(i,j,k));
z = (arrayT(i,j,k));
newarray(q,m,1)= z;
newarray(q,m,2)= y;
newarray(q,m,3)= x;
q=q+1;
t=q
if q==max2+1
q=1;
m=m+1;
end
end
end
end
end
for j = min2:step2:(m-1)
for i = 2
newarray2 (1,j,1) = newarray (i,j,1);
newarray2 (1,j,2) = newarray (i,j,2);
newarray2 (1,j,3) = newarray (i,j,3);
end
end
subplot(1,1,1);plot3(newarray2(:,:,3),newarray2(:,:,2),newarray2(:,:,1),'+')
% subplot(1,1,1);mesh(newarray2(:,:,3),newarray2(:,:,2),newarray2(:,:,1))
end