How to solve this problem?

I have a doubt in my program logic. I dont know how to access the cells. Can somebody help me.
x1={'1' '0' '0' '0' '1' '0'};
x=hex2dec(x1);
v1={'1' '1' '0' '1' '0' '1'};
v=hex2dec(v1);
y1={'0' '0' '0' '0' '0' '0'};
y=hex2dec(y1);
for j=1
for i=1
if x(i) == 0
Lj = y;
else x(i) == 1
Lj = bitxor(y,v);
end
end
Thus, as output I will get Lj= 110101. For i part,x(i), my logic was to access each element in the cell array. For j part,Lj, my logic was to access the entire cell. I want to repeat the steps for each arrays like L1,L2... Can somebody help me to solve this? How can I get access to the complete cell. As output i must have: L1=110101; L2=110100;...and so on

3 comentarios

Bob Thompson
Bob Thompson el 13 de Feb. de 2018
Basic cell array notation uses parentheses, (), to refer to the cell as a whole, while curly braces, {}, refer to the contents of a cell. If you're looking to move through two for loops where j is cell number, and i is element number your indexing should look something like L{j}(i). This calling says you are interested in the contents of cell j, specifically element i.
If you want to use an entire cell for something L(j) is a possible notation, but most computations do not work with 'cell' variables.
Darsana P M
Darsana P M el 13 de Feb. de 2018
I am still not able to access the entire row of Lj. What is the best option?
Bob Thompson
Bob Thompson el 13 de Feb. de 2018
What do you mean by "access"? When I run the code you have written down it seems to recognize and read the cells just fine. It produces output of Lj which is a 5x1 double array, not a cell. If you would like to turn it into a single row (1x5 array) you can do so by transposing Lj = Lj'

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Etiquetas

Preguntada:

el 13 de Feb. de 2018

Comentada:

el 13 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by