if i have some matrix how can i do this operation on it ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Firas Al-Kharabsheh
el 29 de Abr. de 2016
Comentada: Walter Roberson
el 29 de Abr. de 2016
if i have matrix where the size of it is (2,5) and i have a matrix
a = [ 1 3
3 1 ]
* where a matrix show how many of ones will be in the f matrix and between these group of ones just one zero
how to generate matrix like this
f = [ 1 0 1 1 1
1 1 1 0 1 ]
0 comentarios
Respuesta aceptada
Azzi Abdelmalek
el 29 de Abr. de 2016
This is not the best way, but it works
a = [ 1 3
3 1 ]
b=arrayfun(@(x) [0 ones(1,x)],a,'un',0)
c=arrayfun(@(x) cell2mat(b(x,:)),(1:size(a,1))','un',0)
d=cell2mat(c);
out=d(:,2:end)
2 comentarios
Walter Roberson
el 29 de Abr. de 2016
You asked that question already, in http://www.mathworks.com/matlabcentral/answers/281767-how-to-fix-this-code-and-give-the-right-answer .
You duplicate your questions too much, which is a pain to clean up after. The volunteers can either spend time answering code or they can spend time cleaning up questions, but they don't have time to do both.
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing 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!