How can I create a loop and plot a graph after each loop?
4 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I have two questions to do with the same code. So I am going to breakdown the questions below:
- How can I create a for loop that uses a value of beta in each loop?
- As q is a matrix (2 by 1), how can I plot the values of q1 and q2 separately, each against omega_n? (Also note that omega_n changes after each loop as beta changes)
NB: Just assume any values for the matrices below.
beta = 1:1:4; % Array of beta values
w = 0:50E3:300E3;
omega = w.*2.*pi./60; % Array of omega values
omega_n = 3*beta; % Omega_n is dependant on beta
M = [M_11 0; 0 M_22]; % Matrix M
C = [C_11 C_12; C_21 C_22]; % Matrix C
K = [K_11 K_12; K_21 K_22]; % Matrix K
F = [F_1; F_2]; % Matrix F
Z = -(omega.^2).*M + omega.*1i.*C + K; % Matrix Z
Z_inverse = inv(Z); % Inverse of Matrix Z
q = Z\F; % Matrix q
Thanks in advance!
0 个评论
回答(1 个)
KALYAN ACHARJYA
2019-6-14
编辑:KALYAN ACHARJYA
2019-6-14
w = 0:50E3:300E3;
omega = w.*2.*pi./60; % Array of omega values
for beta=1:1:4
omega_n = 3*beta; % Omega_n is dependant on beta
M = [M_11 0; 0 M_22]; % Matrix M
C = [C_11 C_12; C_21 C_22]; % Matrix C
K = [K_11 K_12; K_21 K_22]; % Matrix K
F = [F_1; F_2]; % Matrix F
Z = -(omega.^2).*M + omega.*1i.*C + K; % Matrix Z
Z_inverse = inv(Z); % Inverse of Matrix Z
q= Z\F; % Matrix q
end
For second question clarification needed?
M_11..? M_22...
In each iteration omega_n is scalar (having single value),
Let suppose for first iteration beta=1, therefore omega_n=3
Lets consider q=[2
1] as you mentioned q is 2x1
Now can you elaborate how to do plot between omega_n vs q, I am asking Maths?
2 个评论
uzzi
2022-11-2
Kalyan, I want to create a loop such as for loop or while loop for every 6000 rows in table and plot each loop. I can only code for first 6000 rows. I don't know how to repeat it. Can you help me?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!