Storing values of multiple vectors into one 1:100 matrix?

4 visualizzazioni (ultimi 30 giorni)
v1=50
v3=75
i2=zeros(1, 100)
for v2=1:100
b=[v1; v2; v3]
y=L\b
x=U\y
end
I am using LU decomposition for the equation Ax=b to solve for the current (x=[i1; i2; i3]) when the voltage (b) is v1=50, v3=75, and every value of v2 from 1 to 100. I already have all the values in the 3x3 matrix for resistance values (A). I need to save all the values of i2 that correspond to the changing v2 values and save them all into a 1x100 matrix.

Risposte (1)

Matt J
Matt J il 23 Gen 2018
for v2=1:100
b=[v1; v2; v3]
y=L\b
x=U\y
i2(v2)=x(2);
end
  3 Commenti
Shawna Myatt
Shawna Myatt il 19 Ott 2018
I have a question about this bit of code that you posted. I am new to MatLab, so I was able to follow all of it up until the last line. Why did you use i2(v2) = x(2) to get an output of all of the i2 solutions? I can see where the i2 and the v2 come from, but how does the x(2) fit in?
I want to make sure that I am understanding the concepts behind this. Thanks!
Matt J
Matt J il 20 Ott 2018
Modificato: Matt J il 20 Ott 2018
The 3x1 vector x is the solution to A*x=b and x(2) extracts the second element of x.

Accedi per commentare.

Categorie

Scopri di più su Circuits and Systems 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!

Translated by