フィルターのクリア

Suppress unexpected output to command window

3 ビュー (過去 30 日間)
Ilya Tyuryukanov
Ilya Tyuryukanov 2016 年 5 月 24 日
編集済み: Ilya Tyuryukanov 2016 年 5 月 25 日
In my class constructor I have the following lines:
* some code with inputparser to produce inp
obj.scal = inp.scal;
obj.matrix = inp.scal*matrix; % HERE obj is being printed for some reason
* some code to set other obj properties
Somehow, the object contents are printed to the command window after the second command (it assigns a matrix to the obj.matrix property). The class is a normal "data" class. I'm using Matlab R2015b. I've tried echo off, but it doesn't help. The problem is minor yet annoying.

採用された回答

Steven Lord
Steven Lord 2016 年 5 月 24 日
Are those the only two lines in the constructor?
How are you calling the constructor? Are you calling it like this?
obj = myObjectConstructor()
If so, try adding a semicolon after the constructor call.
obj = myObjectConstructor();
  2 件のコメント
Ilya Tyuryukanov
Ilya Tyuryukanov 2016 年 5 月 25 日
I'm sorry, I've preferred not to put the whole code into the question, but it is of course not all that simple. The constructor is fairly large, there are some assignments to object's properties before and after these two lines, however the object is printed during the constructor execution, and immediately after these two lines. May be I need to send the constructor code to the support team.
Ilya Tyuryukanov
Ilya Tyuryukanov 2016 年 5 月 25 日
編集済み: Ilya Tyuryukanov 2016 年 5 月 25 日
I've found the "bug". There was a missing semicolon in the set.matrix(obj, matrix ) method, i.e. the line
obj.matrix = matrix
was without semicolon. I've overlooked that obj.matrix is not assigned directly, but via its setter method (with some checks). However, nice to know that I may trust Matlab, i.e. there was no internal bug with these newly introduced objects.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by