How do I detect if I’m running MATLAB or Octave?
You could use the following test to differentiate Octave from MATLAB: isOctave = exist(‘OCTAVE_VERSION’, ‘builtin’) ~= 0;
You could use the following test to differentiate Octave from MATLAB: isOctave = exist(‘OCTAVE_VERSION’, ‘builtin’) ~= 0;
The properties that can be set for a figure is referenced here. You could then use: figure_number = 1; x = 0; % Screen position y = 0; % Screen position width = 600; % Width of figure height = 400; % Height of figure (by default in pixels) figure(figure_number, ‘Position’, [x y width height]);
Actually a:b generates a vector. You could use it as index only because the (…) accepts a list also, e.g. octave-3.0.3:10> a = [1,4,7] a = 1 4 7 octave-3.0.3:11> b = [1,4,9,16,25,36,49] b = 1 4 9 16 25 36 49 octave-3.0.3:12> b(a) # gets [b(1), b(4), b(7)] ans = 1 16 49 Now, … Read more
Original answer (Matlab R2015a or lower) The data are: The random variables X, Y: defined as vectors of samples X, Y. The bin edges at the x, y axes: defined by vectors x_axis, y_axis. The edges must obviously be increasing, but need not be uniformly spaced. The resulting PDF and CDF are defined at the … Read more
Yes. Each time you go around, your elseif block is resizing symbol_chip, which is expensive. Instead, rewrite your code so that you have (say) symbol_chip = zeros(max_size, 1); before the loop. Then, change the contents but not the size of symbol_chip. You’ll need to slightly change your approach, but it will be much faster if … Read more
The first place you need to go is Matlab Help on Creating Graphical User Interfaces . Then, you can watch this tutorial video or this one This tutorial is also good.
You can also do it with a trick which works with Matlab version anterior to 2014b (as far back as 2009a at least). However, is will never be as simple as you expected (unless you write a wrapper for one of the solution here you can forget about plot(x,y,{‘r’,’o’,’y’,’g’,’b’})). The trick is to use a … Read more
Without collisions, you can do M = [fieldnames(A)’ fieldnames(B)’; struct2cell(A)’ struct2cell(B)’]; C=struct(M{:}); And this is reasonably efficient. However, struct errors on duplicate fieldnames, and pre-checking for them using unique kills performance to the point that a loop is better. But here’s what it would look like: M = [fieldnames(A)’ fieldnames(B)’; struct2cell(A)’ struct2cell(B)’]; [tmp, rows] = … Read more
According to http://www.mathworks.de/matlabcentral/newsreader/view_thread/238995 feature(‘DefaultCharacterSet’, ‘UTF8’) will change the encoding to UTF-8. You can put the line above in your startup.m file.
Firstly, I think it’s kind of a bug, or at least an unexpected feature, that your syntax x(1:min(5, end)) works at all. When I was at MathWorks, I remember someone pointing this out, and quite a few of the developers had to spend a while figuring out what was going on. I’m not sure if … Read more