recentpopularlog in

kme : matlab   93

« earlier  
user interface - How to draw vertical line on axes in Matlab GUI? - Stack Overflow
My solution was:
axdim = axis;
line([30,30], axdim(3:4), 'linewidth', 2.5, 'color', 'm');
matlab  plotting  graphics  solution 
february 2017 by kme
Shuffle rows of a matlab matrix « Alec's Web Log
Shuffle rows of a matlab matrix

Neat little trick using the keyword end:

M = M(randperm(end),:);
matlab  arrays  solution 
february 2017 by kme
Convert Matlab struct array to cell array - Stack Overflow
This also works for converting a numerical array to a cell array (e.g., storing an array slice in a cell array slice).
matlab  cellarray  arrays  solution 
january 2017 by kme
matlab - index of end in array - Stack Overflow [http://stackoverflow.com/]
end simply stand for the size of the variable at the corresponding dimension

matlab  arrays  solution 
october 2016 by kme
MATLAB - Counting the # of rows that are only numbered with multiples of 5 - Stack Overflow [http://stackoverflow.com/]
you can convert day-hour-min into minutes. Suppose your data is stored in an n-by-3 matrix called data (how original). Then

>> minutes = data * [24*60; 60; 1]; % counting minutes from the begining
Now you have to define the bins' edges (the intervals for summation):

>> edges = min(minutes) : 5 : max(minutes); % you might want to round the lower and upper limits to align with a 5 minute interval.
Use histc to count how many drops in each bin

>> drops = histc(minutes, edges);
matlab  statistics  solution 
october 2016 by kme
Java® Exception and abrupt exit on Mac OS X version 10.10 Yosemite
Whatever this patch does, it fixes the problem with the help documentation not opening.
matlab  mac  osx  java  solution 
september 2016 by kme
How do I download MATLAB R2013b and earlier? - MATLAB Answers - MATLAB Central
The solution is to unzip the installer .zip, then download all the *other* zips into the same extracted folder, alongside the 'install' binary.
Left-click each link to begin downloading all of your products. All of these files must be downloaded to complete the installation. If prompted, choose to Save the files. The files will download into your default installation directory. As each file finishes downloading, move them into the matlab_installer folder you created earlier.

Once all the files are downloaded and moved into the matlab_installer folder, the download is complete. One of the files you downloaded is the MATLAB installer application:

Windows: "matlab_R20XXx_winXX_installer.exe"
MacOS: "matlab_R20XXx_maciXX_installer.zip"
Linux: "matlab_R20XXx_glnxaXX_installer.zip"
matlab  installation  solution 
september 2016 by kme
How can I install MATLAB versions R2011a - R2013a on macOS 10.10 Yosemite or later? - MATLAB Answers - MATLAB Central [http://www.mathworks.com/]
The key was actually using '-javadir' and pointing it to the Java 6 home, because without that, you get an "error contacting MathWorks" during the activation step.

You also need the patch attached to this bug report so that the online help will actually open, instead of just throwing Java exceptions: https://www.mathworks.com/support/bugreports/1098655
matlab  mathworks  java  annoyance  solution 
september 2016 by kme
How do I get the handles of all open figures in MATLAB - Stack Overflow
There are a few ways to do this. One way to do this is to get all the children of the root object:

figHandles = get(0,'Children');

Or you could use the function FINDOBJ:

figHandles = findobj('Type','figure');

If any of the figures have hidden handles, you can instead use the function FINDALL:

figHandles = findall(0,'Type','figure');
matlab  programming  graphics  plotting  solution 
april 2013 by kme
How do I make Matlab help properly display web links for weird URLs? - Stack Overflow
function escapedUrl = escape_url_for_helptext(url)

ixColon = find(url == ':', 1);
if isempty(ixColon)
[proto,rest] = deal('', url);
else
[proto,rest] = deal(url(1:ixColon), url(ixColon+1:end));
end

parts = regexp(rest, '/', 'split');
encodedParts = cellfun(@urlencode, parts, 'UniformOutput', false);
escapedUrl = [proto join(encodedParts, '/')];

function out = join(strs, glue)

strs(1:end-1) = strcat(strs(1:end-1), {glue});
out = cat(2, strs{:});
matlab  urlencode  url  encoding  webdevel  programming  samplecode  solution  textprocessing 
april 2013 by kme
How do I display strings and numbers together in MATLAB? - Stack Overflow
function out = sprintf2(fmt, varargin)
%SPRINTF2 Quasi-"vectorized" sprintf
%
% out = sprintf2(fmt, varargin)
%
% Like sprintf, but takes arrays of arguments and returns cellstr. This
% lets you do formatted output on nonscalar arrays.
%
% Example:
% food = {'wine','cheese','fancy bread'};
% price = [10 6.38 8.5];
% sprintf2('%-12s %6.2f', food, price)
% % Fancier formatting with width detection
% sprintf2('%-*s %6.2f', max(cellfun('prodofsize',food)), food, price)

[args,n] = promote(varargin);
out = cell(n,1);
for i = 1:n
argsi = grab(args, i);
out{i} = sprintf(fmt, argsi{:});
end

% Convenience HACK for display to command line
if nargout == 0
disp(char(out));
clear out;
end

function [args,n] = promote(args)
%PROMOTE Munge inputs to get cellstrs
for i = 1:numel(args)
if ischar(args{i})
args{i} = cellstr(args{i});
end
end
n = cellfun('prodofsize', args);
if numel(unique(n(n > 1))) > 1
error('Inconsistent lengths in nonscalar inputs');
end
n = max(n);

function out = grab(args, k)
%GRAB Get the kth element of each arg, popping out cells
for i = 1:numel(args)
if isscalar(args{i})
% "Scalar expansion" case
if iscell(args{i})
out{i} = args{i}{1};
else
out{i} = args{i};
end
else
% General case - kth element of array
if iscell(args{i})
out{i} = args{i}{k};
else
out{i} = args{i}(k);
end
end
end
matlab  quirk  samplecode  sprintf  textformatting  programming  library  solution 
april 2013 by kme
How can I access the SelectionChangeFcn callback from the Property Inspector in MATLAB 7.4 (R2007a)? - MATLAB & Simulink
If you would like to modify the SelectionChangeFcn, you will need to GET the property of the Button Group graphics object as follows:

get(H,'SelectionChangeFcn')

and similarly you can SET it by :

set(H, 'SelectionChangeFcn',<VALUE>);
matlab  programming  annoyances  bug 
april 2013 by kme
MATLAB: get variable type - Stack Overflow
>> b = 2
b =
2
>> a = 'Hi'
a =
Hi
>> class(b)
ans =
double
>> class(a)
ans =
char
matlab  programming  solution  quirk 
april 2013 by kme
Passing varargin on to another function in MATLAB | Mem
function y = wrapper(x1,x2,varargin)
y = function(varargin{:});
end
matlab  octave  weirdness  quirks  programming  solution 
april 2013 by kme
GUI with Matlab outline
17. Using global variables

Necessary due to Matlab not having static variables
Must declare in each function used
matlab  solution  programming  ayfkm  devel 
april 2013 by kme
image processing - Changing Transparent Background to White in Matlab - Stack Overflow
I = imread('file.png', 'BackgroundColor',[1 1 1]); imwrite(I, 'file.jpg')

[0.5,0.5,0.5] for 50% grey.
matlab  graphics  png  transparency  plotting  solution 
april 2013 by kme
Issues when using mex with 2011b in Mac OSX 10.7.3 - Newsreader - MATLAB Central
"and change line 167 from
SDKROOT='/Developer/SDKs/MacOSX10.6.sdk/'
to
SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/'

Then everything should work fine."

Also required if some idiot moves his Xcode.app to a subfolder of /Applications.
matlab  mex  compiler  mac  osx  solution  devel 
april 2013 by kme
TRIGDEMO - File Exchange - MATLAB Central
This needs to show axes in increments of fractions of pi. Try:

set(gca,'XTick',-pi:pi/2:pi)
set(gca,'XTickLabel',{'-pi','-pi/2','0','pi/2','pi'})
matlab  trig  samplecode  needshelp 
march 2013 by kme
line - Matlab code to draw a tangent to a curve - Stack Overflow
function test hh figure 1 ; clf, hold on grid on x 0:0.01:2*pi; f @ x sin x ; fprime @ x cos x ; plot x, f x , r axis tight D ; L ; set hh, ... WindowButtonMotionFcn , @mouseMove,... WindowButtonDownFcn , @mouseClick ; function mouseMove varargin coords get gca, currentpoint ; xC coords 1 ; if ishandle D delete D ; end D plot xC, f xC , ko ; end function mouseClick obj, varargin switch get obj, selectiontype % actions for left mouse button case normal coords get gca, currentpoint ; xC coords 1 ; yC f xC ; a fprime xC ; b yC-a*xC; if ishandle L delete L ; end L line 0; 2*pi , b; a*2*pi+b ; case alt % actions for right mouse button case extend % actions for middle mouse button case OPEN % actions for double click otherwise % actions for some other X-mouse-whatever button end end end
matlab  plotting  tangentline  tangent  math  solution  interactive 
february 2013 by kme
How to get application root path? - Newsreader - MATLAB Central
% Change the current folder to the folder of this m-file.
% (The line of code below is from Brett Shoelson of The Mathworks.)
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
matlab  tipsandtricks  solution 
february 2013 by kme
« earlier      
per page:    204080120160

Copy this bookmark:





to read