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

19 visualizzazioni (ultimi 30 giorni)
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";

Risposte (1)

Ayush
Ayush il 5 Ago 2024
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!

Prodotti


Release

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by