i want to get bex(j), bin(j) as gex(i), gin(i), how to do that and insert another for loop inside that code

1 Ansicht (letzte 30 Tage)
i want to get bex(j), bin(j) as gex(i), gin(i), how to do that and insert another for loop inside that code
code:
Rmin = 1e5
Rmax = 1e6
Gmin = 1.0/Rmax
Gmax = 1.0/Rmin
X = table2array(in_mn)
y=w{1}
b= w{2}
%nitialize gex and gin to be matrices the same size as y.
%Then loop over all elements of y
gex = zeros(size(y));
gin = zeros(size(y));
bex= zeros(size(b) %)i want make for loop as in that in gex anf gin
bin= zeros(size(b))
for i = 1:numel(y) % numel(y), not length(y)
if y(i)>=0,
gex(i) = Gmax*y(i) +Gmin*(1-y(i));
gin(i) = Gmin;
else
gex(i) = Gmin;
gin(i) = -Gmax*y(i) +Gmin*(1+y(i));
end
end

Akzeptierte Antwort

C B
C B am 1 Dez. 2022
Bearbeitet: C B am 1 Dez. 2022
Rmin = 1e5
Rmax = 1e6
Gmin = 1.0/Rmax
Gmax = 1.0/Rmin
X = table2array(in_mn)
y=w{1}
b= w{2}
%nitialize gex and gin to be matrices the same size as y.
%Then loop over all elements of y
gex = zeros(size(y));
gin = zeros(size(y));
bex= zeros(size(b)); %)i want make for loop as in that in gex anf gin
bin= zeros(size(b));
for i = 1:numel(y) % numel(y), not length(y)
if y(i)>=0,
gex(i) = Gmax*y(i) +Gmin*(1-y(i));
gin(i) = Gmin;
else
gex(i) = Gmin;
gin(i) = -Gmax*y(i) +Gmin*(1+y(i));
end
end
%%%% Added loop
for i = 1:numel(b)
if b(i)>=0,
bex(i) = Gmax*b(i) +Gmin*(1-b(i));
bin(i) = Gmin;
else
bex(i) = Gmin;
bin(i) = -Gmax*b(i) +Gmin*(1+b(i));
end
end
I was not able to run it because follwinf value was not present
X = table2array(in_mn)
y=w{1}
b= w{2}

Weitere Antworten (0)

Kategorien

Mehr zu Parallel Computing Fundamentals finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by