I have a class. There are some properties and anonymous functions into this class:
classdef Parabolic
properties (Access = public)
a = 0;
b = 0;
c = 0;
F = @(t, x) 0;
%%There are othere code
end
properties (Access = private)
Z = [];
u = [];
method = 0;
border = @(k, psi) 0;
%%There are othere code
end
%%There are othere code
methods(Access = public)
function Calculate(this)
[X, P] = meshgrid(solver.La : solver.h : solver.Lb, solver.Ta : solver.tau : solver.Tb);
a = this.a
b = this.b;
c = this.c;
this.Z = this.F(X, P); % Function
end
end
end;
I initialize some properties and after it, I execute this method it:
But I have such error:
Undefined function or variable 'a'.
What does it cause this error?

3 件のコメント

Adam
Adam 2015 年 11 月 26 日
編集済み: Adam 2015 年 11 月 26 日
Given what you have shown I see no reason for such an error.
Which line is throwing the error?
a is not even used in your Calculate function so whether it is defined or not shouldn't matter.
If the error where that the property a does not exist you would get a different error message.
Your function F also does nothing so I'm confused as to what the aim of the code is. If you simplified it just to keep it short it looks like you simplified too much.
hedgehogues
hedgehogues 2015 年 11 月 26 日
編集済み: hedgehogues 2015 年 11 月 26 日
I rewrite simply example here:
Look please.
You can create some files and start my example. Please. I don't understand how to fix this bug.
Adam
Adam 2015 年 11 月 26 日
Your example code here looks quite a lot different to that. For a start it uses neither global nor eval anywhere which is a big improvement, but I still don't see the purpose of using a function handle here rather than a regular class method if what you actually want is for your function to use class properties anyway.
I have use function handles as class properties before so I'm not saying it is never of use, but in this case I am not seeing the value.

サインインしてコメントする。

 採用された回答

hedgehogues
hedgehogues 2015 年 11 月 26 日

0 投票

I found the solve. You can see my account on the stackoverflow.

1 件のコメント

Adam
Adam 2015 年 11 月 26 日
Using eval instead of function handles is a bad solution in general, but I guess if it works for you then that is fine for as long as it does work!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFunction Creation についてさらに検索

質問済み:

2015 年 11 月 26 日

コメント済み:

2015 年 11 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by