Putting array indexes into a larger one

1 vue (au cours des 30 derniers jours)
center
center le 6 Mai 2020
I have 200x1 bitcells, every cell element is made by 3x1 char strings, represents 3 bits like '101' . I am reading this cells as integers, then I attain -1 or 1 value. The problem is when I try to put this -1 and 1s into 600x1 volts array, it puts wrong values, some elements are missed so stays 0. I checked the singlevolts array always true in every iteration but I couldn't put that values in 600x1 array correctly. Any help will appreciated, thank you community. Stay safe!
for m=1:1:200
for n=1:1:3
if (str2num(bitcells{m}(n)) == 0)
singlevolts(n) = -1
else singlevolts(n) = 1
end
end
volts(m*1) = singlevolts(1)
volts(m*2) = singlevolts(2)
volts(m*3) = singlevolts(3)
end

Réponse acceptée

Deepak Gupta
Deepak Gupta le 6 Mai 2020
Modifié(e) : Deepak Gupta le 6 Mai 2020
Hello Mert,
I am not completely sure what you want to do but got some impression so have made some modification in your code.
for m=1:1:200
for n=1:1:3
if (str2num(bitcells{m}(n)) == 0)
singlevolts(n) = -1
else singlevolts(n) = 1
end
end
volts(3*(m-1)+1) = singlevolts(1);
volts(3*(m-1)+2) = singlevolts(2);
volts(3*(m-1)+3) = singlevolts(3);
end
If this doesn't solve your problem, then attach your cell array, with required end result.
Cheers.
  1 commentaire
Deepak Gupta
Deepak Gupta le 6 Mai 2020
Modifié(e) : Deepak Gupta le 6 Mai 2020
for m=1:200
for n=1:3
if (str2num(bitcells{m}(n)) == 0)
singlevolts= -1
else singlevolts= 1
end
volts(3*(m-1)+n) = singlevolts;
end
end
It can do the same thing.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by