Nested for-loop to calculate RMS of curves of varying parameters

1 view (last 30 days)
Below is the code I have so far to calculate the RMS between observed data and calculated data of varied deltaK parameter. I now want to add another for loop to this code so that two model parameters are varied. The additional parameter to be varied is theta=degtorad(45:2:135). So, I'm looking for a final RMS with dimensions 46x31. How do I write this?
j = 0;
deltaK = (0.002:0.0001:0.005);
for deltaK =(0.002:0.0001:0.005);
i=0;
for x = min(assessment1_data1(:,1)) : max(assessment1_data1(:,1));
i = i+1;
h = 5;
theta = (pi/2);
I = 1.117;
A = 0;
T = 47500;
d = 17.8;
AMP = (2*deltaK*T*((sin(I))/(sin(atan(tan(I) / cos(A)))))^2 * sin(theta));
a = (2.*atan(tan(I)/cos(A))-theta);
deltaT(i)= (2.*deltaK.*T.*(sin(I)/sin(atan(tan(I)/cos(A))).^2.*sin(theta))).*(sin(a).*(atan((x+d)./h)-atan((x-d)./h))-(cos(a)./2).*log(((x+d).^2+h^2)./((x-d).^2+h^2)));
end
j=j+1;
%Calculating RMS from Part 2.1
x= min(assessment1_data1(:,1)):max(assessment1_data1(:,1));
obs=assessment1_data1(:,2);
RMS(j)=sqrt((sum((obs-deltaT').^2))./(length(obs)));
end

Answers (0)

Categories

Find more on Function Creation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!