# code for calculate points

1 visualizzazione (ultimi 30 giorni)
Nara Lee il 24 Apr 2021
Commentato: Nara Lee il 24 Apr 2021
hello everyone, i want to write a code to calculate these for 121 points
for n = 1:nfreq
T1=[B(n) C(n);D(n) H(n)]
T2=[R(n) G(n);E(n) L(n)]
T=T1*inv(T2)
do you know I could do this?
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Clayton Gotberg il 24 Apr 2021
The code you've already written will calculate those values for each of 121 points.
for n = 1:nfreq
T1=[B(n) C(n);D(n) H(n)]
T2=[R(n) G(n);E(n) L(n)]
T=T1*inv(T2)
end
If you want to save the results of those calculations to use later, you can save the values in an array during the loop. For this case, with each thing you want to save being a matrix itself, I would recommend a cell array.
for n = 1:nfreq
T1=[B(n) C(n);D(n) H(n)];
T2=[R(n) G(n);E(n) L(n)];
T{n}=T1*inv(T2); % The curly braces are used to index in cell arrays
end
% example T
{{[1 2; 4 3]},{[5 3; 7 6]}}
% ^ ^
% T{1} T{2}
% 1 2 5 3
% 4 3 7 6
##### 4 CommentiMostra 3 commenti meno recentiNascondi 3 commenti meno recenti
Nara Lee il 24 Apr 2021
then i do ei{n}=eig(T1*inv(T2))
it worked
thank you for ypur help

Accedi per commentare.

### Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!