This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| clc | |
| clear all; | |
| close all; | |
| %testing matlab script on github gist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| clc; | |
| BIN_SIZE = 2 | |
| tempWinData = [1,2;2,4;3,6;4,8;5,10;6,12;7,14;8,2;9,1;10,NaN;10,5] | |
| %tempWinData = [1,1;2,2;3,3;3,9]; | |
| times = tempWinData(:, 1); | |
| vals = tempWinData(:, 2); | |
| bins = times(1):BIN_SIZE:times(end); | |
| [bincounts,binIndex] = histc(times(:,1),bins); | |
| %insert any unbinned data to last bin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % Authors | |
| % Reza Arfa <rezaarfa (at)gmail.com> | |
| % | |
| % License | |
| % The program is free to use for non-commercial and academic purposes. | |
| % | |
| % Changes | |
| % 01/01/2013 (!) | |
| clc; close all; clear all; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = [ 1 2 3 4' ]; | |
| b = padarray(a,[0 3], NaN, 'pre') | |
| b = padarray(b,[0 4], NaN, 'post') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %A=[5,8,16;4,1,8;-4,-4,-11]; %real eigvects | |
| %http://math.mit.edu/~gs/linearalgebra/ila0601.pdf | |
| A=[.8,.3;.2,.7]; | |
| [V,D] = eig(A); | |
| [evals,idx] = sort(diag(D)); | |
| EigenValues = evals | |
| evects = V(:,idx); | |
| EigenVects = evects |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load gong | |
| sound(y,Fs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % based on http://stackoverflow.com/questions/22792020/matlab-accumarray-weighted-mean | |
| data = [10 1;30 1;20 2;30 1;20 4;20 6] | |
| %{ | |
| data = | |
| 10 1 | |
| 30 1 | |
| 20 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % see http://www.mathworks.com/matlabcentral/answers/68510-remove-rows-or-cols-whose-elements-are-all-nan | |
| out = A(:,any(~isnan(A))); % for columns | |
| out = A(any(~isnan(A),2),:); %for rows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %% filter range of values | |
| rawData = 1900:5:2100; | |
| from = 1982; | |
| to_excluded = 2015; | |
| indexes = 1:length(rawData); | |
| %declare indexes for the whole data range | |
| filter = logical(rawData(:) >= from & rawData(:) < to_excluded); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %% using reshape() to change a multi dimensional array into a smaller | |
| % dimension without loosing values | |
| %vector into matrix 5x2 (rowxcol) | |
| A = 1:10; | |
| B = reshape(A,[5,2]) | |
| %reshape matrix to have 3 columns, discarding rows | |
| A = magic(6); | |
| B = reshape(A,[],3) |
OlderNewer