Is there an analagous command to VB's 'with'?
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
Paulo Silva
2011-2-13
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
0 个评论
Walter Roberson
2011-2-14
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!