필터 지우기
필터 지우기

Improving modal analysis code

조회 수: 5 (최근 30일)
Pinco
Pinco 2012년 8월 6일
Hi everyone!
My code resolves a dynamic problem with coupled equation, so I study this problem in the modal space.
I have the matrix of MODAL solution (each column is the solution for time t*, with t* = 0,1,2,.. T) but I want to know the NODAL SOLUTION, so I wrote this code to execute inverse modal transformation (PHI is the modal matrix while BI2 is a translation coordinates matrix, such as g = BI2*PHI*y, where g is in the nodal space while y in the modal):
% y is the modal solution matrix
% g is the nodal solution matrix
g = zeros(size(y));
for i=1:length(y)
g(:,i) = BI2*PHI*y(:,i);
end
In fact, the modal inverse relation is true column by column [y(:,i) -> g(:,i)].
How can I improve my code? This for loop is very slow when I have a lot of dof.. I think I have to rewrite it, but I don't know how.
Thanks in advance! Pinco

채택된 답변

Matt Kindig
Matt Kindig 2012년 8월 6일
Hi Pinco,
What are the dimensions of BI2, PHI, and y? You might be able to use matrix multiplication directly to eliminate the loop. You may just be able to write it as:
g = BI2*PHI*y;
  댓글 수: 2
Pinco
Pinco 2012년 8월 8일
Thanks a lot for your answer.
size(y) = (n,1)
size(BI2) = (n,n)
size(PHI) = (n,n)
size(g) = (n,t)
where n is the number of dof selected and t is the number of time-point used (i.e if T = 250s and I use a discretization dt = 1s, t=0:250).
Now I can test your code ;)
Pinco
Pinco 2012년 8월 18일
It works very well! I'm sorry for this time in my answer. Thank you very much!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by