Storing values of multiple vectors into one 1:100 matrix?
조회 수: 1 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
Matt J
2018년 1월 23일
for v2=1:100
b=[v1; v2; v3]
y=L\b
x=U\y
i2(v2)=x(2);
end
댓글 수: 3
Shawna Myatt
2018년 10월 19일
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!
참고 항목
카테고리
Help Center 및 File Exchange에서 Circuits and Systems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!