Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
What the...?

Subject: What the...?

From: David

Date: 7 Oct, 2010 02:32:06

Message: 1 of 8

 dt = DateTime.ToOADate(UTCdeploy(i));
??? The class System.DateTime has no property or method named 'ToOADate'.

Error in ==> rt_driver_DO at 136
            dt = DateTime.ToOADate(UTCdeploy(i));
 
>> methods DateTime

Methods for class System.DateTime:

Add GetHashCode ToShortTimeString
AddDays GetType ToString
AddHours GetTypeCode ToUniversalTime
AddMilliseconds IsDaylightSavingTime eq
AddMinutes Subtract ge
AddMonths ToBinary gt
AddSeconds ToFileTime le
AddTicks ToFileTimeUtc lt
AddYears ToLocalTime minus
CompareTo ToLongDateString ne
DateTime ToLongTimeString plus
Equals ToOADate
GetDateTimeFormats ToShortDateString

WTF???!!!

Subject: What the...?

From: Steven_Lord

Date: 7 Oct, 2010 13:55:33

Message: 2 of 8



"David " <dgol461@ecy.wa.gov> wrote in message
news:i8jbf6$qf4$1@fred.mathworks.com...
> dt = DateTime.ToOADate(UTCdeploy(i));
> ??? The class System.DateTime has no property or method named 'ToOADate'.
>
> Error in ==> rt_driver_DO at 136
> dt = DateTime.ToOADate(UTCdeploy(i));
>
>>> methods DateTime
>
> Methods for class System.DateTime:
>
> Add GetHashCode ToShortTimeString
> AddDays GetType ToString
> AddHours GetTypeCode ToUniversalTime
> AddMilliseconds IsDaylightSavingTime eq
> AddMinutes Subtract ge
> AddMonths ToBinary gt
> AddSeconds ToFileTime le
> AddTicks ToFileTimeUtc lt
> AddYears ToLocalTime minus
> CompareTo ToLongDateString ne
> DateTime ToLongTimeString plus
> Equals ToOADate GetDateTimeFormats
> ToShortDateString
> WTF???!!!

The message is misleading (and I will note this to the development staff),
but there is an actual problem with your code.

You're calling the ToOADate method of the System.DateTime class as though it
were a static method of the class, but ToOADate is NOT a static method of
this class. That means you need to call this method with an instance of the
System.DateTime class as input.

s = System.DateTime;
ToOADate(s)

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: What the...?

From: David

Date: 7 Oct, 2010 15:37:04

Message: 3 of 8

"Steven_Lord" <slord@mathworks.com> wrote in message <i8kjgl$9nd$1@fred.mathworks.com>...
>
>
> "David " <dgol461@ecy.wa.gov> wrote in message
> news:i8jbf6$qf4$1@fred.mathworks.com...
> > dt = DateTime.ToOADate(UTCdeploy(i));
> > ??? The class System.DateTime has no property or method named 'ToOADate'.
> >
> > Error in ==> rt_driver_DO at 136
> > dt = DateTime.ToOADate(UTCdeploy(i));
> >
> >>> methods DateTime
> >
> > Methods for class System.DateTime:
> >
> > Add GetHashCode ToShortTimeString
> > AddDays GetType ToString
> > AddHours GetTypeCode ToUniversalTime
> > AddMilliseconds IsDaylightSavingTime eq
> > AddMinutes Subtract ge
> > AddMonths ToBinary gt
> > AddSeconds ToFileTime le
> > AddTicks ToFileTimeUtc lt
> > AddYears ToLocalTime minus
> > CompareTo ToLongDateString ne
> > DateTime ToLongTimeString plus
> > Equals ToOADate GetDateTimeFormats
> > ToShortDateString
> > WTF???!!!
>
> The message is misleading (and I will note this to the development staff),
> but there is an actual problem with your code.
>
> You're calling the ToOADate method of the System.DateTime class as though it
> were a static method of the class, but ToOADate is NOT a static method of
> this class. That means you need to call this method with an instance of the
> System.DateTime class as input.
>
> s = System.DateTime;
> ToOADate(s)
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

I figured it was something like that (I'm still getting use to MATLAB's method calling syntax--different from C and Python, as you know) but I'm glad you acknowledge that the error message is "misleading" (I would say, on its face, oxymoronic, but you say tomahto, I say tomayto...)

DG

Subject: What the...?

From: Steven_Lord

Date: 7 Oct, 2010 15:47:08

Message: 4 of 8



"David " <dgol461@ecy.wa.gov> wrote in message
news:i8kpf0$ol6$1@fred.mathworks.com...
> "Steven_Lord" <slord@mathworks.com> wrote in message
> <i8kjgl$9nd$1@fred.mathworks.com>...

*snip*

> I figured it was something like that (I'm still getting use to MATLAB's
> method calling syntax--different from C and Python, as you know) but I'm
> glad you acknowledge that the error message is "misleading" (I would say,
> on its face, oxymoronic, but you say tomahto, I say tomayto...)

Really, if the message had one more word it would be exactly correct and not
misleading:

    ??? The class System.DateTime has no property or static method named
'ToOADate'.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: What the...?

From: Brad Stiritz

Date: 13 Feb, 2011 20:30:05

Message: 5 of 8

Hi Steve,

Regarding your comments...

> The message is misleading (and I will note this to the development staff),
> but there is an actual problem with your code.
>
> You're calling the ToOADate method of the System.DateTime class as though it were a static method of the class, but ToOADate is NOT a static method of this class. That means you need to call this method with an instance of the System.DateTime class as input.
>
> s = System.DateTime;
> ToOADate(s)

I just wanted to mention that I've seen this same error message even when I passed a class object as the first argument to the method, exactly per the MATLAB documentation:

============
Either of the following statements is correct syntax for calling a method where obj is an object of the class defining the compute method:

obj.compute(inc)
compute(obj,inc)
============

Here's my experience:

% What class is (outCV)?
>> class(outCV)
ans = CellVector

% Get generic cell vector of strings : CellVector class methods :
>> cvMethods = methods('CellVector');

% Is 'cellfun' a listed method within (cvMethods)?
K>> any(strcmp('cellfun',cvMethods))
ans = 1

% Try to call CellVector.cellfun() using so-called "function notation":
>> CellVector.cellfun(outCV,fFilter)
??? The class CellVector has no property or method named 'cellfun'.

% Now try calling the same method using so-called "dot notation:
>> outCV.cellfun(fFilter)
ans = 1.00
................

Please let me know if I'm making some kind of mistake here. Otherwise, I'll plan to report via a Service Request..

Thanks,
Brad

Subject: What the...?

From: Steven_Lord

Date: 14 Feb, 2011 01:33:36

Message: 6 of 8



"Brad Stiritz" <sorry.no.contact@info.net> wrote in message
news:ij9f0d$rj2$1@fred.mathworks.com...
> Hi Steve,
>
> Regarding your comments...
>
>> The message is misleading (and I will note this to the development
>> staff), but there is an actual problem with your code.
>>
>> You're calling the ToOADate method of the System.DateTime class as though
>> it were a static method of the class, but ToOADate is NOT a static method
>> of this class. That means you need to call this method with an instance
>> of the System.DateTime class as input.
>>
>> s = System.DateTime;
>> ToOADate(s)
>
> I just wanted to mention that I've seen this same error message even when
> I passed a class object as the first argument to the method, exactly per
> the MATLAB documentation:
>
> ============
> Either of the following statements is correct syntax for calling a method
> where obj is an object of the class defining the compute method:
>
> obj.compute(inc)
> compute(obj,inc)
> ============

That's correct, assuming that the compute method accepts two inputs, the
first of which is an instance of the class for which the compute method is
defined.

> Here's my experience:
>
> % What class is (outCV)?
>>> class(outCV)
> ans = CellVector
>
> % Get generic cell vector of strings : CellVector class methods :
>>> cvMethods = methods('CellVector');
>
> % Is 'cellfun' a listed method within (cvMethods)?
> K>> any(strcmp('cellfun',cvMethods))
> ans = 1
>
> % Try to call CellVector.cellfun() using so-called "function notation":
>>> CellVector.cellfun(outCV,fFilter)
> ??? The class CellVector has no property or method named 'cellfun'.

That's the correct syntax to call a STATIC method of the CellVector class --
name of the class, followed by a period, followed by the method name.
[Static methods _can_ accept an instance of the class but don't _have_ to.]

http://www.mathworks.com/help/techdoc/matlab_oop/brdqiu3.html

To call a non-static method of the CellVector class on the outCV instance of
this class, use either:

outCV.cellfun(fFilter)

or:

cellfun(outCV, fFilter)

> % Now try calling the same method using so-called "dot notation:
>>> outCV.cellfun(fFilter)

Yes, that will work. Note something that's present in your previous attempt
that's not present in this one?

Basically if you need to call it using the _name_ of the class, it's a
static method. If you call it on an _instance_ of the class, it's generally
not static. Rarely should you need to use both the name _and_ an instance
of the class.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: What the...?

From: Brad Stiritz

Date: 14 Feb, 2011 02:42:03

Message: 7 of 8

Hi Steve,

Thanks so much for clarifying, much appreciated.

>Rarely should you need to use both the name _and_ an instance of the class.

Yes, I'm sure this is true. I had gotten myself confused working with depfun() & trying to disambiguate overloaded class methods.

Brad

Subject: What the...?

From: Sargondjani

Date: 19 Dec, 2012 11:37:08

Message: 8 of 8

I dont understand the error yet. I also get it. My code is:

     E_vec = NaN(1,par.T);
     for it = 1:par.T;
      E_vec(it) = interp1(var.K(:,it),bm.E_pol(1,:,it,z(iz)),bm.sim.avg_K(1,it));
     end

When i run the thing i get the following error message:

??? The class bm has no property or method named 'sim'.

Error in ==> plot_pol_fun_v2 at 180
      E_vec(it) =
      interp1(var.K(:,it),bm.E_pol(1,:,it,z(iz)),bm.sim.avg_K(1,it));

But if i put a 'dbstop if error', then if i type " bm.sim.avg_K(1,it)" i get the value that i want (and "bm.sim.avg_K" is a vector, as it should be).

what could be possibly wrong here? (bm is a structure, and so is sim)

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us