-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcombvec.m
executable file
·34 lines (29 loc) · 965 Bytes
/
combvec.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function output = combvec(vec1,vec2);
% (C) Nick Holschuh - Amherst College - 2020 (Nick.Holschuh@gmail.com)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The inputs are as follows:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% vec1 -
% vec2 -
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The outputs are as follows:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% output -
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
s1 = size(vec1);
s2 = size(vec2);
if s1(2) == 1 & s2(2) == 1 %%%%%% The vertical case
nvec1 = matrix_to_vector((vec1*ones(size(vec2))')');
nvec2 = repmat(vec2,length(vec1),1);
output = [nvec1 nvec2];
elseif s1(1) == 1 & s2(1) == 1 %%%%%%%% The horizontal case
nvec1 = matrix_to_vector((vec1'*ones(size(vec2)))');
nvec2 = repmat(vec2',length(vec1),1);
output = [nvec1'; nvec2'];
end