Combining 2 Arrays(of equal or different dimensions)
Show older comments
Hello, I have hit a wall while doing my ex-homework so I can prepare for my exam.Anyways, here it goes:
Assume that you have two vectors named A2 and B2 of different lengths. Create a vector C2 that combines A2 and B2. In addition, if you run out of elements in one of the vectors, C2 contains the elements remaining from the longer vector. Example: if A2 = [1, 2, 3, 4, 5, 6] and B2 = [10, 20, 30], then C2 = [1, 10, 2, 20, 3, 30, 4, 5, 6] if A2 = [1, 2, 3] and B2 = [10, 20, 30, 40, 50], then C2 = [1, 10, 2, 20, 3, 30, 40, 50]
Also there is this second one, Write a MATLAB program that takes two 2D arrays (they may be of different dimensions) and extracts them into 1D array. Example: If A= [1 2 3; 4 5 6; 3 2 5] and B= [4 5; 1 2; 3 9] Output= [1 2 3 4 5 4 5 6 1 2 3 2 5 3 9] If A= [1 2 3; 4 5 6] and B= [4 5; 1 2; 3 9] Output= [1 2 3 4 5 4 5 6 1 2 3 9]
I would love it if someone is capable of helping me I have failed to solve it no matter how hard I tried. Union function didnt work aswell as there is duplicates in the output array. Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Matrices and 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!