How to use the result of mn matrix at each loop step to do the calculation of amn?

2 次查看(过去 30 天)
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)

采纳的回答

David Hill
David Hill 2021-5-24
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
  1 个评论
Mark
Mark 2021-5-25
Thank you so much David Hill!
Wow! This is my first time to see how the {} operate, could you expain what is the difference between {} and ()? For the first for loop section, I originally tried to coding "mn (f)" but it indicated errors.
Really appreciate your help : )

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by