How to use the result of mn matrix at each loop step to do the calculation of amn?
1 view (last 30 days)
Show older comments
There are two matrix of mn in the for loop in my command window (Please see the code below) .
The first matrix is mn= [1 1;1 3;3 1;3 3] and the second matrix is mn=[1 1;1 3;1 5;3 1;3 3;3 5;5 1;5 3;5 5].
Then I would like to plug the first matrix value and the second matrix value respectively into the the second loop function to get the two set of amn value.
Now I can only get the second set of amn value(9 elements) but how can I store the first set of amn (4 element ).
My goal is to sum different set of amn value to see the convegence behavior.
Should I store the mn matirx? or is there any suggestion way to modify my coding.
Thank you very much!!
clc
clear
format long
E=209e+3;
q=1;
h=15;
D=6.459478e+07;
a=600;b=2400;
% Control the value of mn
c=2
for f=1:c
k=[3:2:1+2*c];
[T1, T2] = meshgrid(1:2:k(f));
mn = [T1(:), T2(:)]
end
len=length(mn);
amn=zeros(1,len);
for i=1:len
m=mn(i,1);
n=mn(i,2);
amn(i)=(16*q/(m*n*D*pi^6))*(1/((m/a)^2+(n/b)^2)^2);
end
test_combine=sum(amn)
0 Comments
Accepted Answer
David Hill
on 24 May 2021
format long
E=209e+3;
q=1;
h=15;
D=6.459478e+07;
a=600;b=2400;
% Control the value of mn
c=2;
for f=1:c
k=[3:2:1+2*c];
[T1, T2] = meshgrid(1:2:k(f));
mn{f} = [T1(:), T2(:)];
end
for f=1:c
len=length(mn{f});
amn=zeros(1,len);
for i=1:len
m=mn{f}(i,1);
n=mn{f}(i,2);
amn(i)=(16*q/(m*n*D*pi^6))*(1/((m/a)^2+(n/b)^2)^2);
end
test_combine(f)=sum(amn);
end
More Answers (0)
See Also
Categories
Find more on Get Started with Control System Toolbox 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!