I have to make a function that takes 3 inputs like e0, e1 and e2. The function will have 2 outputs x and y.
x will be the combinations of e0, e1 and e2. y will be a column vector containing sums of columns of x.
The following conditions must be met when creating the function:
- inputs
e0,e1ande2each have a single number. - if user doesn't enter a value for the input it set to 0 as default.
- if user doesn't enter any input then a message that no input has been entered should be shown.
Here's an example:
combination pattern of X (first 3 columns): pattern for y is the sum of x
1 1 1 3
2 1 1 4
3 1 1 5
1 2 1 4
2 2 1 5
3 2 1 6
1 3 1 5
2 3 1 6
and so on... and so on....
So far I have only been able to do this much with x and y displayed separately.
function [x,y]=create(e0,e1,e2)
switch nargin
case 2
e1=0;
e2=0;
case 1
e2=0;
case 0
disp('no input')
end
I googled my problem and found that combvec and allcomb should help but i cant figure out how.. Please help any answer or hint will be a great help.