save rows from an array

조회 수: 3 (최근 30일)
samuel herrera
samuel herrera 2021년 11월 17일
답변: Robert U 2021년 11월 17일
G=10*10-9;% conductividad
l=1*10^-3;
c=10*10^-9;
u=4*pi*10^-7;
e=(l*c)/u;
g=(u*G)/l;
vs=1;
f=[60 1000];
zs=50;
long=100;
x=0:0.1:100;
%condicione de la carga
zl=-1.2839j;
for ii=1:length(f)
w(ii)=2*pi*f(ii);
z0(ii)=((j*w(ii)*l)/(g+j*w(ii)*c))^(1/2);
prop(ii)=(j*w(ii)*l*(g+j*w(ii)*c))^(1/2);
A{ii}=[(z0(ii)+zs),(z0(ii)-zs);(z0(ii)-zl)*exp(-prop(ii)*long),(z0(ii)+zl)*exp(prop(ii)*long)];
ainv{ii}=inv(A{ii});
vo{ii}=ainv{ii}*[z0(ii)*vs;0];;
vp1{ii}=vo(1)
vp2{ii}=vo(2);
end
hi, does any one know how can i save vp1 and vp2 in list, is always showing me error

답변 (1개)

Robert U
Robert U 2021년 11월 17일
Hi samuel herrera,
I guess, you would like to store the content of the cell array vo in vp1 and vp2, respectively. You have to address the correct cell:
G = 10*10-9;% conductividad
l = 1*10^-3;
c = 10*10^-9;
u = 4*pi*10^-7;
e = (l*c)/u;
g = (u*G)/l;
vs = 1;
f = [60 1000];
zs = 50;
long = 100;
x = 0:0.1:100;
%condicione de la carga
zl = -1.2839j;
for ii=1:length(f)
w(ii) = 2*pi*f(ii);
z0(ii) = ((1j*w(ii)*l)/(g+1j*w(ii)*c))^(1/2);
prop(ii) = (1j*w(ii)*l*(g+1j*w(ii)*c))^(1/2);
A{ii} = [(z0(ii)+zs),(z0(ii)-zs);(z0(ii)-zl)*exp(-prop(ii)*long),(z0(ii)+zl)*exp(prop(ii)*long)];
ainv{ii} = inv(A{ii});
vo{ii} = ainv{ii}*[z0(ii)*vs;0];
vp1{ii} = vo{ii}(1);
vp2{ii} = vo{ii}(2);
end
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 8.003843e-26.
vp1
vp1 = 1×2 cell array
{[0.0256 + 0.0244i]} {[0.1030 + 0.0851i]}
vp2
vp2 = 1×2 cell array
{[9.9755e-15 + 9.8287e-15i]} {[-1.4010e-53 - 6.0898e-54i]}
Kind regards,
Robert

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by