"TS.Global" I got this as a part of a matlab code. Can anyone help to understand what does mean? I have seen this dot operator as a part of structure; is this mean the same?

If any documentation regarding this; kindly share.....

댓글 수: 2

@Walter Roberson Actually it is from a matlab function code. My doubt is why we use that dot operator; I have seen dot operator with structure data. Can we use anywhere else other that numerical calculation?

댓글을 달려면 로그인하십시오.

 채택된 답변

The dot operator such as TS.Global can mean:
  • That TS is a struct(), and Global is a field in the struct
  • That TS is an object, and Global is a property of the object. It is not necessarily an object created in MATLAB: it might be an object created in Java for example
  • That TS is an object, and Global is a method associated with the object. It is not necessarily an object created in MATLAB; it might be an object created in Java for example
  • That TS is a package created with a +TS directory and Global is a function defined in the package; https://www.mathworks.com/help/matlab/matlab_oop/scoping-classes-with-packages.html
TS.Global appears to be used in the Model Based Calibration toolbox. When I chase back the source of TS from old mbcmodels/@xregoptmgr source code that I find online, then it appears that the variable TS is a "model", probably of class mbcmodels or a subclass of that.
Possibly these days the Global property corresponds to https://www.mathworks.com/help/mbc/mbccommandline/global.html

댓글 수: 14

@Walter Roberson @Image Analyst class(TS) shows 'char'. It is from function 'mle'.
Models= TS.Global;
Nf= length(Models);
st=1;
for i=1:Nf
m= Models{i};
b= double(m);
Tin= Terms(m);
b(Tin) = Bmle(st:st+sum(Tin)-1);
Models{i} = update(m,b);
st= st+sum(Tin);
end
if (DatumType(TS.Local)==1 | DatumType(TS.Local)==2) & ~RFstart(TS.Local);
TS.datum= Models{1};
end
TS.Global= Models;
Then TS is not what you think it is. It's a simple string variable (actually a character array) which means it has no such property or method. Here is a simple example to illustrate:
TS = 'abcdefg';
class(TS)
ans = 'char'
TS.Global
Dot indexing is not supported for variables of this type.
Why would anyone think that this TS had a Global property or method? Show how you created TS by "mle".
Nop, instead of typing
class(TS)
OP types
class TS
which returns char
What shows up for
which -all mle
The version of mle that I find in the Statistics Toolbox does not contain that code or any reference to TS.Global
@Walter Roberson I used this command for finding the code
type mle
Execute the command
which -all mle
and tell us the output
Also, which MATLAB version are you using?
Do what Walter says. For me, I see
>> which -all mle
C:\Program Files\MATLAB\R2022a\toolbox\stats\stats\mle.m
@Walter Roberson While executing I got this:
\Program Files\MATLAB\R2021a\toolbox\stats\stats\mle.m
\Program Files\MATLAB\R2021a\toolbox\mbc\mbcmodels\@xregtwostage\mle.m % xregtwostage method
\Program Files\MATLAB\R2021a\toolbox\mbc\mbctools\@mdev_local\mle.m % mdev_local method
and version I am using is R2021a
OK I think that looks fine. Now how did you create TS? Where is the line of code that says
TS = ................whatever it is......................
Maybe you can just attach the m-file with a paperclip icon if it's too complicated.
put a breakpoint at the line
Models= TS.Global;
in the mle function that is being invoked. Then run the code. When it stops at the line
class(TS)
and show us the result, and also show us the output
dbstack
Thank you @Walter Roberson @Image Analyst for your answers and the support. It would definitely benefit me.
"\Program Files\MATLAB\R2021a\toolbox\stats\stats\mle.m"
This was the file that I was needed.
@Walter Roberson Yes, Thank You very much....
But you should have already had that file if you had the stats toolbox installed.
  1. Did you not have the stats toolbox installed and had to buy it?
  2. Or did you have your own version of mle.m that it was using instead of the toolbox version?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

TS is probably either a class or a structure. Global could be a field of the TS structure. Or if TS is a static class, Global could be a method of the static class. Or if TS is an instance of some class (with a different name) then Global could be a method or the class or a property of the class.
But why didn't you answer Walter's question when he asked you to put this in your code and tell us what it says:
class(TS)

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

질문:

2022년 8월 17일

댓글:

2022년 8월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by