Insert two elements in a multidimensional array
Mostrar comentarios más antiguos
Hi, I want to insert two elements (h1,h2) into my multi array called xh after its initialized all with zeros.
N = 50;
xh = zeros(2,N);
[h1,h2] = cruza(x(:,p1),x(:,p2));
%Insert h1 and h2 into xh
The function "cruza" returns elements to insert into xh
function [xh1,xh2] = cruza(xp1,xp2)
D=2;
pc = randi([1 D]);
xh1 = [xp1(1:pc) ; xp2(pc+1:D)];
xh2 = [xp2(1:pc); xp1(pc+1:D)];
3 comentarios
the cyclist
el 18 de Feb. de 2019
Let's suppose that N = 5 instead of 50. Then
xh = [0 0 0 0 0;
0 0 0 0 0]
What size are h1 and h2? (Please give an example of what they look like.) Where do you want to insert them into xh? How do we know that?
Cesar Ramirez
el 18 de Feb. de 2019
madhan ravi
el 18 de Feb. de 2019
please explicitly state your desired output
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Multidimensional Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!