Insert two elements in a multidimensional array
Show older comments
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 Comments
the cyclist
on 18 Feb 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
on 18 Feb 2019
madhan ravi
on 18 Feb 2019
please explicitly state your desired output
Accepted Answer
More Answers (0)
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!