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)
VIJAY
VIJAY el 5 de Ag. de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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
jonas
jonas el 5 de Ag. de 2018
what's the problem with find?

Respuestas (2)

Jan
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:

Image Analyst
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.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by