Adding Two Arrays Alternatively to make Third Array
6 views (last 30 days)
I have two arrays, called "Force X Values" and "Force Y values". I am attaching the files and their pictures respectively.
Force X Values:
Force Y Values:
I want to join these two arrays in such a way that the first value comes from ForceX Values and the second values comes from Force Y values.
The total size of the resultant array wiill be then 128x1. To do it manually, it would look like
[253.756605837273 + 0.00000000000000i
-465.372363772121 + 0.00000000000000i
6.13965893028579 - 3.73527288491552i
11.1240857825471 + 2.09884355966154i]
Does anyone know how to do it using a loop or without it?
More Answers (1)
Jan on 23 Aug 2020
% Arbitrary test data:
ForceX = rand(64, 1) + 1i * rand(64, 1);
ForceY = rand(64, 1) + 1i * rand(64, 1);
% Methode 1:
ForceXY = zeros(128, 1);
ForceXY(1:2:end) = ForceX;
ForceXY(2:2:end) = ForceY;
% Methode 2:
ForceXY = [ForceX.'; ForceY.'];
ForceXY = ForceXY(:);