matlab - Replicate elements of cell 1 to match length of cell 2 -


I tried to find the answer to this question in advanced search but could not find one. I could forget it, in which case, apology.

I think this is a simple question, but I am having trouble fixing it. I have a cell array, in which each cell has an array of doubles. First of all, I need to know which after which the cell is the longest array length, the array elements of other cells should be repeated to match the longest length.

That is, for example:

resp = {[1 3 2 6 4] [4 2 5]}

I do not have a priority resp {1} or resp {2} is larger.

is a new cell array resp_new = {[1 3 2 6 4] [4 2 5 4 5]}. It means, {2} to match the length of resp {2} to connect its own elements (potentially random).

So far, I can be summarized as follows:

  response = {[1 3 2 6 4] [4 2 5]}; To find the longest array of doubles in my cell array, I could have something like this: val = cellphone (@ (x) numel (x), response); Longest = reactions (val == max (val)); % Or something, only the length is returning TMP = selphan (@ length, reaction);   

I have a problem, I do not know how to move with the length of the other elements to repeat your elements in the lowest array in order to move forward.

Any help would be greatly appreciated! Thanks and best regards.

Mark

should do this:

  Answer = {[1 3 2 6 4] [4 2 5]} Size = most = maximum (cellphone (@Numail, reaction)); Reaction = cellphone (@ (x) [x x (randy (number (x), 1, size long - number (x))), reactions, 'uniform output', false); First, it takes the form of the longest sequence, then, it uses the  cellphone , and each array is  x  For, it automatically inserts with  N  random elements, where  N = size long - number (x) .  

Result:

  & gt; & Gt; Reactions {:} ans = 1 3 2 6 4 ans = 4 2 5 5 2    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -