Effacer les filtres
Effacer les filtres

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

4 vues (au cours des 30 derniers jours)
Jeff
Jeff le 13 Fév 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

Réponses (2)

Paulo Silva
Paulo Silva le 13 Fév 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 le 14 Fév 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.

Catégories

En savoir plus sur Specifying Target for Graphics Output dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by