Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Jeff
Jeff am 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

Antworten (2)

Paulo Silva
Paulo Silva am 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 am 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.

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by