The error is : "未识别类 'matlab.gr​aphics.pri​mitive.Sur​face' 的方法、属性或字段 'DataTipTemplate'。"

In Primitive surface appearance and behavior - MATLAB (mathworks.com) ,I get that the surface has the DataTipTemplate attribute.
My code is as following:
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
s = surface(X,Y,Z);
s.DataTipTemplate.DataTipRows(1).Label = "SYM";

답변 (1개)

Hello @莹,
From the code snippet provided by you as well as the error message shown, it seems that the data tip object is not present in the script thus it is being shown as unrecognized for the "DataTipTemplate" properties. I tried running the code provided to face the same error and to resolve this issue, you need to instantiate a "datatip" object first that creates a data tip and then use the "DataTipTemplate" properties to create your own custom data tips. You can refer to the below code snippet for your reference:
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
s = surface(X,Y,Z);
dt = datatip(s,64,142); % here you instantiate/create the data tip to be modified later using DataTipTemplate
s.DataTipTemplate.DataTipRows(1).Label = "SYM";
For more information on how to control the interactivity of a grahics object, in your case the data tip content, you can refer to the following documentations:
Hope this helps!

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

릴리스

R2024a

질문:

莹
2024년 8월 5일

댓글:

莹
2024년 8월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by