time | Calls | line |
---|
| | 7 | function [ar_a_wth_zero] = fft_array_add_zero(varargin)
|
| | 8 | %% FFT_ARRAY_ADD_ZERO Add zero to array without changing size
|
| | 9 | %
|
| | 10 |
|
| | 11 | %% Default
|
| | 12 | % use binomial as test case, z maps to binomial win prob, remember binom
|
| | 13 | % approximates normal.
|
| | 14 |
|
< 0.001 | 1 | 15 | params_len = length(varargin);
|
| 1 | 16 | bl_input_override = 0;
|
< 0.001 | 1 | 17 | if (params_len == 2)
|
< 0.001 | 1 | 18 | bl_input_override = varargin{2};
|
| 1 | 19 | end
|
| | 20 |
|
< 0.001 | 1 | 21 | if (bl_input_override)
|
| | 22 |
|
| | 23 | % if invoked from outside overrid fully
|
< 0.001 | 1 | 24 | [ar_a, ~] = varargin{:};
|
< 0.001 | 1 | 25 | [fl_a_min, fl_a_max, it_a_n] = deal(min(ar_a), max(ar_a), length(ar_a));
|
< 0.001 | 1 | 26 | bl_display_addzero = false;
|
| | 27 |
|
| | 28 | else
|
| | 29 |
|
| | 30 | clear all;
|
| | 31 | close all;
|
| | 32 |
|
| | 33 | [fl_a_min, fl_a_max, it_a_n] = deal(-20, 50, 11);
|
| | 34 | ar_a = linspace(fl_a_min, fl_a_max, it_a_n);
|
| | 35 | bl_display_addzero = true;
|
| | 36 |
|
| 1 | 37 | end
|
| | 38 |
|
| | 39 | %% Add in Zero
|
< 0.001 | 1 | 40 | if (ismember(0, ar_a))
|
0.006 | 1 | 41 | ar_a_wth_zero = sort(unique(ar_a));
|
| | 42 | else
|
| | 43 | ar_a = linspace(fl_a_min, fl_a_max, it_a_n-1);
|
| | 44 |
|
| | 45 | if (ismember(0, ar_a))
|
| | 46 | % add a mid point between 0 and lowest savings point above zero.
|
| | 47 | ar_a_wth_zero = [(ar_a(2)-ar_a(1))/2, ar_a];
|
| | 48 | ar_a_wth_zero = sort(unique(ar_a_wth_zero));
|
| | 49 | else
|
| | 50 | ar_a_wth_zero = [0 ar_a];
|
| | 51 | ar_a_wth_zero = sort(unique(ar_a_wth_zero));
|
| | 52 | end
|
| 1 | 53 | end
|
| | 54 |
|
| | 55 | %% Display
|
| 1 | 56 | if (bl_display_addzero)
|
| | 57 |
|
| | 58 | disp('ar_a');
|
| | 59 | disp(ar_a);
|
| | 60 |
|
| | 61 | disp('ar_a_wth_zero');
|
| | 62 | disp(ar_a_wth_zero);
|
| | 63 |
|
| | 64 | end
|
< 0.001 | 1 | 65 | end
|
Other subfunctions in this file are not included in this listing.