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 visualización (últimos 30 días)
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

Respuesta aceptada

C B
C B el 1 de Dic. de 2022
Editada: C B el 1 de Dic. de 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}

Más respuestas (0)

Categorías

Más información sobre Parallel Computing Fundamentals en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by