Getting error message "Unable to resolve the name obj.function."
11 views (last 30 days)
Show older comments
I'm having a problem calling a fuction of a handle from another handle class. Testing the function itself in the command window works fine, but when i call the function from a different class, i get the error message "Unable to resolve the name obj.function". I already tried to restore the default path of matlan as suggested here. Broken down, the code of the two classes looks like this:
1 classdef Filter < handle
2 properties (Access = private)
3 f_high = 0;
4 f_tol = 0;
5 end
6
7 methods (Access = public)
8
9 %Construktor
10 function obj = Filter(f_high, f_tol)
11 obj.setHighFrequencyBorder(f_high);
12 obj.setFilterTolerance(f_tol);
13 Signal.checkSamplingFrequency(f_high, f_tol);
14 end
15 end
1 classdef TestSignal < handle
2
3 properties (Access = private)
4 samplingFrequency = 0;
5 end
6
7 methods (Access = private)
8 %Constructor
9 function obj = TestSignal(samplingFrequency)
10 obj.setSamplingFrequency(samplingFrequency);
11 end
12 end
13
14 methods (Static)
15 function inst = getInstance(samplingFrequency)
16 persistent testSignal;
17 if isempty(testSignal)
18 testSignal = TestSignal(samplingFrequency);
19 inst = testSignal;
20 else
21 inst = testSignal;
22 end
23 end
24 end
25
26 methods (Access = public)
27
28 %Setter
29 function setSamplingFrequency(obj, samplingFrequency)
30 obj.samplingFrequency = samplingFrequency;
31 end
32 end
33 end
The Issue occurs when calling the function in line 13 of the class Filter when calling the function in line 29 of class TestSignal. I've created an object called "Signal", so in theory the class Filter should "know" this funtion.
Class TestSignal is implemented as a Singleton.
Thanks a lot upfront for helping out.
0 Comments
Answers (1)
Walter Roberson
on 7 Sep 2020
Your posted code has no property or method named Signal and no global variable by that name. It also does not appear to be somehow nested such that Signal might somehow be defined in an outer scope.
You also do not have a class named Signal that has a static method named checkSamplingFrequency . Instead you have a class named TestSignal that has a static method named getInstance()
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!