How can I create a loop and plot a graph after each loop?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
KALYAN ACHARJYA
el 14 de Jun. de 2019
Editada: KALYAN ACHARJYA
el 14 de Jun. de 2019
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 comentarios
uzzi
el 2 de Nov. de 2022
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?
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!