# Solving unknown matrix with iterated column vector

3 vues (au cours des 30 derniers jours)
ajdlot6 le 24 Mai 2023
Modifié(e) : ajdlot6 le 24 Mai 2023
Hi!
I have a question about how to solve unknown matrix with known column vectors where one of the vectors has to keep iterating with different values. I have a system:
F = C*s
where
F is a known column matrix 4x1 of form F = [40; 0; 0; 0] and 40 has to keep iterating over the process to the 2nd, 3rd, 4th spot while other values stay 0,
C is unknown square matrix 4x4,
s is known column matrix 4x1 of random numbers
What I'm currently using is
f = 40;
F = [f; 0; 0; 0]; % this has to be iterated with f changing places
S = randn(4,1);
C = F*pinv(S); % I'm not sure about the validity of this, but at least gives me some results
now I have tried searching for a similar question but haven't found much - I can't find anything that would give me a "suitable" result. From the code you can see that I get the first result, since I set the F that way, but then whatever I try to do the iteration with (they told me to "loop", but I noticed that some don't recommend it), I didn't get a good answer. Also, with pinv() I always get the same result when I change the position of f and I don't think that's the right approach for this case.
Does anyone have any tips on how to solve this? Or maybe I'm just using the wrong approach. Any help would be greatly appreciated! :)
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

Luca Ferro le 24 Mai 2023
i'm not really quite sure about what operation you are trying to solve and how to solve it, but for theF iteration part this works:
f = 40;
S = randn(4,1);
for ii=1:4
F=zeros(1,4);
F(ii)=f
%HERE THE OPERATION YOU WANT TO CARRY
end
F = 1×4
40 0 0 0
F = 1×4
0 40 0 0
F = 1×4
0 0 40 0
F = 1×4
0 0 0 40
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
ajdlot6 le 24 Mai 2023
Modifié(e) : ajdlot6 le 24 Mai 2023
That already helps me a lot! Basically I have get all values for C and that's why I have the C = F*pinv(S) operation. But with the code you gave me I get what I pretty much wanted so thank you! :)

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!

Translated by