How can I perform an operation on each element of a vector individually using a for loop?
6 次查看(过去 30 天)
显示 更早的评论
I have impedance values from a separate file saved as a vector, the second column is the magnitude and the third column is the phase. I want to convert the magnitude and phase to compelx form for a set of frequency values, but when I try to do it for every frequency value it results in a single impedance value which is not what I want. This is what my code looks like right now. My issue is with the second for loop.
%Frequency from scan
Sweep;
for k=2:1:50
F(:,k)
s=2*pi*F*i;
end
%Impedance from scan, converted to complex
for j=1:1:49
Zp=Zp(j,2)*cos(Zp(j,3))+i*Zp(j,2)*cos(Zp(j,3))
end
%Line Impedance Calculations
LineImpedanceCalculation;
%Impedance Matrix Formulation
num6=0*F;
den6=1;
sys6=num6/den6;
num7=0*F;
den7=1;
sys7=num7/den7;
%Node 1
Z11=Zp+sys1+sys3
Z12=sys1+sys6+sys7
Z13=sys3+sys6+sys7
%Node 2
Z21=sys1+sys6+sys7
Z22=Zp+sys2+sys1
Z23=sys2+sys6+sys7
%Node 2
Z31=sys3+sys6+sys7;
Z32=sys2+sys6+sys7;
Z33=Zp+sys2+sys1;
%Final Impedance Matrix
Zmat = [Z11; Z21; Z31]
%Admittance Matrix and Eigenvalues
Ymat = inv(Zmat)
X=eig(Ymat)
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Switches and Breakers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!