![]() ![]() The new (documented) syntax automatically type-casts the data to the specified data type, were possible, something that the undocumented syntax presented above does not. However, I feel that there are important drawbacks to the new functionality compared to the one presented here. For example:Ĭlassdef double scalar complex = 1 + 2i end end % This causes an error:Ĭlassdef double complex = 1 + 2i end endĪddendum April 28, 2016: Matlab R2016a now has a similar documented functionality. Note that we have to enter the dimensionality (scalar/vector/matrix) first, since “complex” is not accepted as a valid dimensionality value. In order to enable complex values, we can also add the undocumented “complex” attribute. Mc.MethodList(49).InputTypes % Īddendum November 11, 2015: Apparently, when using the syntax, Matlab only allows the property to receive real values. If you ever discover other such buried treasures, please do let me know by email or a comment.Īddendum June 21, 2013: As Sebastian Hölz mentioned in his comment below, the general syntax appears to be: I love to discover such undocumented treasures by digging in Matlab’s function. But I thought it’s important enough to bring to the attention of the community. ![]() I admit there’s not much original work here by me – it’s basically all by Amro (and Donn Shull for the UDD part). Note that setting the type as above seems to override any set method that may have been specified for the property.Īmro came across this syntax in an internal class in R2013a ( but it also worked in R2012a, and probably older versions as well… This syntax apparently supports all primitive types ( char, int32, double, struct, cell etc.), in addition to any user-defined ones (just use any class name). HeaderLength = 100 % not ok - should be a uint16 While setting the 'HeaderLength' property of Packet: In fact, this was the solution of Jonas, another StackOverflow heavyweight: One simple way to prevent unintentional MCOS property updates is to override the property’s set method. Unfortunately, MCOS does not provide a documented way of specifying the property type as in UDD. We can still do this today, since UDD classes are still supported, side-by-side with the newer MCOS classes. A detailed explanation was provided here. An easy way to do this is by setting the second argument of the schema.prop function. In UDD classes, we can do this easily by setting the property’s DataType meta-property. For example, if we have a class with properties Width and Height, we probably want to restrict their possible values to numbers, to prevent setting a string or struct value. In a nutshell, Amro found an undocumented way to specify a class object property’s type, in such a way that would prevent accidental setting to an incompatible value. ![]() But a few days ago I was pleasantly surprised to read Amro’s comment about an entirely new and undocumented aspect of Matlab MCOS classes.Īmro is a top contributor on StackOverflow, where he frequently answers questions before I even get any subscription notification about them… His answers are generally characterized by a deep technical understanding of Matlab, and I’ve learned quite a lot from him in the past few years. last month I discovered the additional undocumented classdef Description and DetailedDescription attributes, and updated that article accordingly. By default, MATLAB leaves some empty space for tick labels, axis labels, title, etc.When I wrote about the undocumented aspects of classdef properties half a year ago, I did not expect to learn of another major undocumented aspect in Matlab’s class-object system. Note that in the example above, I made the axis cover the entire figure (no gray area in the figure). The same holds for the other two margins: Here you can see the bottom and left margins equal to 10mm. If you want to try this yourself, just be aware that some viewers ( Adobe Reader) might be using a custom DPI not matching the system default resolution (mine at 96 pixels/inch). Without a printer at hand, I am using a virtual screen ruler to check the measurements Simply display the PDF file with your preferred viewer, and the set the zoom level at 100% (I am using Sumatra PDF). Set(hFig, 'Units','centimeters', 'Position',/2) %# figure size displayed on screen (50% scaled, but same aspect ratio) ![]() YSize = Y - 2*yMargin %# figure size on paper (widht & hieght) XSize = X - 2*xMargin %# figure size on paper (widht & hieght) YMargin = 1 %# bottom/top margins from page borders XMargin = 1 %# left/right margins from page borders Below is an example for producing a PDF file with dimensions 420 x 297 mm (A3 size), where the margins between the plot and the file borders are 10 mm each (top,bottom,left,right). As explained, you need to set the Paper*** properties of the figure. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |