Please, help! I get an NaN's cannot be converted to logicals. Error in Untitled (line 22) while tol_V2(i) && tol_V3(i) >= 0,00005; error. How can I fix it?

7 visualizzazioni (ultimi 30 giorni)
clc;
clear all;
y12 = -40j;
y23 = -20j;
y13 = -20j;
i=1;
V1 = 1;
V2(i) = 1.05+0j;
V3(i) = 1+0j;
s3 = 5+4j;
p2 = 4.07;
tol_V2(i) = 1;
tol_V3(i) = 1;
while tol_V2(i) && tol_V3(i) >= 0,00005;
V3(i+1)= (V1*y13 + V2(i)*y23 - conj(s3)/conj(V3(i)))/(y13 + y23);
q2(i+1) = -imag(conj(V2(i))*((y12 + y13)*V2(i)- V3(i+1)* y23 - V1*y12));
s2(i+1) = p2 + 1j*q2(i+1);
V2(i+1) = (V3(i)*y23 + V1*y12 + conj(s2(i))/conj(V2(i)))/(y12 + y23);
e(i+1) = sqrt(real(V2(i + 1)^2 - imag(V2(i + 1))^2));
V2(i+1) = e(i+1)+ imag(V2(i + 1));
tol_V2(i+1) = abs(V2(i+1)-V2(i));
tol_V3(i+1) = abs(V3(i+1)-V3(i));
tol_V2(i) = tol_V2(i+1);
tol_V3(i) = tol_V3(i+1);
i = i+1;
end

Risposta accettata

Jan
Jan il 15 Mag 2021
Modificato: Jan il 15 Mag 2021
Before the loop, tol_V2 is a scalar. Inside the first iteration you set tol_V2(i) and tol_V3(i) with i == 1. But after increasing i by 1, tol_V2(2) is not define. Solution:
tol_V2(i + 1) = abs(V2(i+1)-V2(i));
% ^^^
tol_V3(i + 1) = abs(V3(i+1)-V3(i));
% ^^^
  3 Commenti

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Argument Definitions 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