Undefined function 'isnan' for input arguments of type 'Nodes2'
古いコメントを表示
I have created a class Nodes that creates a node with properties value, next, and previous. Next and previous are set to nan and Nodes 2 takes in an item which is the value.
I have created a seperate handle class that uses Nodes2, it has an obj.head that is set to nan as its property. I have attached some troubleshooting I have below to confirm my filepath is correct.

I am trying to run
if (~isnan(obj.head))
which is where the error occurs and where the code stops.
I am not sure what to do and how to move forward.
Thanks for any ideas!
採用された回答
その他の回答 (1 件)
J. Alex Lee
2022 年 10 月 5 日
For reference, a related question that shows more of the actual classes in question: https://www.mathworks.com/matlabcentral/answers/1817710-inserted-value-failing-to-show-up-in-list?s_tid=mlc_ans_men_view&mentions=true#comment_2398560
classdef DLL < handle
properties
head; % head node of the DLL
end
methods
function obj = DLL()
obj.head = Nodes2.empty();
end
end
end
And in Nodes2
classdef Nodes2
properties
value % the value that will be stored in our DLL
previous % pointer to previous node
next % pointer to next node
end
methods
end
function obj = Nodes2(item)
obj.value = item;
obj.next = Nodes2.empty;
obj.previous = Nodes2.empty;
end
end
So you can test with the vanilla "isempty"?
1 件のコメント
Walter Roberson
2022 年 10 月 6 日
Using an empty object seems like a good approach to me.
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!