You can also download it from my matlab file exchange and rate it :-)
18.7.12
Concatenate arrays with different sizes in Matlab
You can also download it from my matlab file exchange and rate it :-)
3.5.12
Custom Colors for Matlab Plots
This is a(nother) simple function I wrote for matlab, it can also be downloaded from my file exchange at mathworks:
http://www.mathworks.com/matlabcentral/fileexchange/36514-custom-colors-for-plots
In plot graphs, often it's needed to use a several colors that can be easily differentiated on a first look on the graphic. With this function you can call easily (by name or by code) a selection of 15 colors.
It's very simple and there are more elegant ways to do it, but I think it's a very functional solution.
17.4.12
Save Workspace to Struct
And now it's also available at the Matlab Central (if you want to rate it, which is always welcome): http://www.mathworks.com/matlabcentral/fileexchange/36257-save-workspace-to-struct
27.12.11
Merging Multiple Cells into Single One in Excel
'Macros for Horizontal and Vertical concatenation
'Copyright, Andrés Gonzalez, 2008
Sub mezclar() 'horizontal concatenation
For Each fila In Selection.Rows
mensaje = ""
For Each celda In fila.Cells
mensaje = mensaje & celda.Value & " "
Next
fila.Clear
fila.Cells(1, 1).Value = mensaje
Next
End Sub
Sub mezclarV() 'vertical concatenation
For Each columna In Selection.Columns
mensaje = ""
For Each celda In columna.Cells
mensaje = mensaje & "- " & celda.Value & Chr(10)
Next
columna.Clear
columna.Cells(1, 1).Value = mensaje
Next
End Sub
Albert | Einstein |
Nikola | Tesla |
albert einstein |
nikola tesla |
- albert | - einstein |
20.12.11
Replace Error Message with Custom Message in Excel
'This function takes away errors in formulas and replace them for something
'more meaningful (a string defined by the user)
'example: quitarerror(1/0;"you can't divide by zero")
' result:"you can't divide by zero"
'Copyright, Andrés González, 2008
Function quitarerror(dato As Variant, reemplazo As Variant) As Variant
If IsError(dato) = True Then
quitarerror = reemplazo
Else
quitarerror = dato
End If
21.6.11
Resample a Matrix in Matlab
function newmatrix=resampmatrix(matrix,newlen)
%----------------
%this function uses linear interpolation to change the number of rows in a
%matrix.
%Copyright, 2011, Andrés González
%----------------
[rows cols]=size(matrix);
newmatrix=[];
for i=1:cols
len=rows;
x=1:len;x=x';y=matrix(:,i);
xx=1:(len-1)/(newlen-1):len;
xx=xx';
yy=interp1(x,y,xx,'linear');
newmatrix=[newmatrix yy];
end
Resample in Matlab
function newvector=resample(vector,newlen)
%%%%%%%%%%%%%%%%%%%%
%This function uses linear interpolation to change the number of samples
% Copyright 2011 Andrés Gonzalez
%%%%%%%%%%%%%%%%%%%%
len=length(vector);
x=1:len;x=x';y=vector;
xx=1:(len-1)/(newlen-1):len;
xx=xx';
yy=interp1(x,y,xx,'linear');
newvector=yy;
end