Comments on: Scalar Roulette https://blogs.mathworks.com/loren/2010/07/09/scalar-roulette/?s_tid=feedtopost Loren Shure is interested in the design of the MATLAB language. She is an application engineer and writes here about MATLAB programming and related topics. Fri, 16 Jul 2010 02:20:43 +0000 hourly 1 https://wordpress.org/?v=6.2.2 By: Kenneth Eaton https://blogs.mathworks.com/loren/2010/07/09/scalar-roulette/#comment-31500 Fri, 16 Jul 2010 02:20:43 +0000 https://blogs.mathworks.com/loren/2010/07/09/scalar-roulette/#comment-31500 The second option using param/value pairs seems like the best of those three.

Another option would be that the second argument is always the number of contours and the third argument is always a vector of contour values. As with other functions (like MAX) you could just leave the second input as empty if it isn’t necessary:

contour(Z,n);     % Plots n contours
contour(Z,[],0);  % Plots 1 contour at 0
contour(Z,[],v);  % Plots the contours in vector v
]]>
By: Loren https://blogs.mathworks.com/loren/2010/07/09/scalar-roulette/#comment-31495 Tue, 13 Jul 2010 21:06:51 +0000 https://blogs.mathworks.com/loren/2010/07/09/scalar-roulette/#comment-31495 Matt-

Sudden is a funny word in this context – subplot was this way from before I ever used MATLAB so I don’t know why it was designed row-wise. But I can definitely see how the inconsistency causes problems!

–Loren

]]>
By: Matt Fig https://blogs.mathworks.com/loren/2010/07/09/scalar-roulette/#comment-31494 Tue, 13 Jul 2010 16:30:39 +0000 https://blogs.mathworks.com/loren/2010/07/09/scalar-roulette/#comment-31494 One inconsistency that has tripped me up in the past is the row-wise assignments of the SUBPLOT function. For example, given the command:

subplot(2,2,2)

which, according to the documentation, breaks the the Figure window into an 2-by-2 matrix of axes and selects the 2nd one, we should expect the current axes to match any other 2nd element of any other MATLAB matrix.

A = zeros(2,2); % A 2-by-2 matrix
A(2) = 5; % Change the second element.

These commands put a five in the lower left element, yet the second axes addressed by the above subplot corresponds to the third element in A (the upper right), not the second.

Yes it is documented that the axes are counted row-wise, but why this sudden change from MATLAB column-dominated addressing?

]]>
By: FM https://blogs.mathworks.com/loren/2010/07/09/scalar-roulette/#comment-31488 Fri, 09 Jul 2010 21:55:21 +0000 https://blogs.mathworks.com/loren/2010/07/09/scalar-roulette/#comment-31488 I prefer the option no.2.
Something like:

contour(Z,’number’,8);
contour(Z,’levels’,[-4 0 4]);

This would have the advantage to remain compatible with the present syntax, if the 2nd input argument is not a string.

]]>