Putting array indexes into a larger one
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
center
el 6 de Mayo de 2020
Editada: Deepak Gupta
el 6 de Mayo de 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
0 comentarios
Respuesta aceptada
Deepak Gupta
el 6 de Mayo de 2020
Editada: Deepak Gupta
el 6 de Mayo de 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 comentario
Deepak Gupta
el 6 de Mayo de 2020
Editada: Deepak Gupta
el 6 de Mayo de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!