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 次查看(过去 30 天)
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

采纳的回答

C B
C B 2022-12-1
编辑:C B 2022-12-1
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}

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by