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 Center および File ExchangeParallel Computing Fundamentals についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by