Clear Filters
Clear Filters

Is there an analagous command to VB's 'with'?

4 views (last 30 days)
Jeff
Jeff on 13 Feb 2011
In VB, use can use 'with' to executes a series of statements on a single object. Example: With textbox1 .Height = 100 .Width = 500 End With
My code: freq(col).idx=freq(col).idx+1; freq(col).xtrmum(freq(col).idx,1).start=M(ii-2,col); freq(col).xtrmum(freq(col).idx,1).second=M(ii-1,col); freq(col).xtrmum(freq(col).idx,1).xtrm=M(ii,col); freq(col).xtrmum(freq(col).idx,1).fourth=M(ii+1,col); freq(col).xtrmum(freq(col).idx,1).end=M(ii+2,col); freq(col).xtrmum(freq(col).idx,1).tstep=ii; ... freq(col).xtrmum(freq(col).idx,1).poly=polyfit(x,y,2); freq(col).xtrmum(freq(col).idx,1).polyD3=polyfit(x,y,3); freq(col).xtrmum(freq(col).idx,1).polyD4=polyfit(x,y,4);| ...
My code if I could use 'with': freq(col).idx=freq(col).idx+1; with freq(col).xtrmum(freq(col).idx,1) .start=M(ii-2,col); .second=M(ii-1,col); .xtrm=M(ii,col); .fourth=M(ii+1,col); .end=M(ii+2,col); .tstep=ii; ... .poly=polyfit(x,y,2); .polyD3=polyfit(x,y,3); .polyD4=polyfit(x,y,4); ... end with
I can't find a 'with' or anything in Matlab help. Is there one? Thanks, Jeff

Answers (2)

Paulo Silva
Paulo Silva on 13 Feb 2011
You can use the set function to change object properties
a=figure; %create a figure
set(a,'name','Myfigure','color',[1 0 0]) %change the name and color

Walter Roberson
Walter Roberson on 14 Feb 2011
No there is not. However, if the object referenced is a handle object, then setting a variable equal to the prefix object (handle) and then using that variable should work. I am not certain that the same thing will work for non-handle object: I think it would depend upon the details of the object.

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!