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 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hagar Hendy
il 1 Dic 2022
Modificato: Chetan Bhavsar
il 1 Dic 2022
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
0 Commenti
Risposta accettata
Chetan Bhavsar
il 1 Dic 2022
Modificato: Chetan Bhavsar
il 1 Dic 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}
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Scatter Plots 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!