Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Find does not work according to the condition?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have
a=[1 2 3];
b=[4 5 6 7];
c=[7 2]
How do I make them above different size matrix a single array like as follows:
s=[1 2 3 0;
4 5 6 7;
7 2 0 0];
1 comentario
Respuestas (2)
Jan
el 5 de Ag. de 2018
Editada: Jan
el 5 de Ag. de 2018
a = [1 2 3];
b = [4 5 6 7];
c = [7 2];
Data = {a, b, c}; % Better use a cell array instead of a bunch of variables
Len = cellfun('prodofzize', Data);
M = zeros(numel(Data), max(Len));
for k = 1:numel(Data)
M(k, 1:Len(k)) = Data{k};
end
By the way: You find some matching functions searching in the FileExchange:
0 comentarios
Image Analyst
el 5 de Ag. de 2018
This works:
a=[1 2 3];
b=[4 5 6 7];
c=[7 2]
maxLength = max([length(a), length(b), length(c)])
output = zeros(3, maxLength);
output(1, 1:length(a)) = a;
output(2, 1:length(b)) = b;
output(3, 1:length(c)) = c
find() was not needed.
0 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!