Quantcast
Channel: MATLAB Central Newsreader - tag:"patch"
Viewing all articles
Browse latest Browse all 25

Re: Get automatically 3D position of a data cursor on a patch

$
0
0


"someone" <someone@somewhere.net> wrote in message
news:mo6br2$c7p$1@newscl01ah.mathworks.com...
> mjrizy70 <abaszadeh.mj@gmail.com> wrote in message
> <dbSdnT0pZqoc1zvInZ2dnUU7-eudnZ2d@giganews.com>...
>> when i use the code below, i got "Attempt to reference field of
>> non-structure array." error. Can u please help me?
>>
>> % reading a head 3-D model
>>
>> [V,F] = read_vertices_and_faces_from_obj_file('head.obj');
>> fig=figure(1);
>> trisurf(F,V(:,1),V(:,2),V(:,3));
>> x=zeros(1,10);
>> y=zeros(1,10);
>> z=zeros(1,10);
>>
>> datacursormode on
>> dcmObj = datacursormode(fig);
>> set(dcmObj,'SnapToDataVertex','on','Enable','on');
>>
>> for i=1:10
>> w = waitforbuttonpress;
>> point = getCursorInfo(dcmObj);
>> POINT=point.Position;
>> x= POINT(1);
>> y= POINT(2);
>> z = POINT(3);
>> end
>>
>
> For which line do you get the error message?
> I'm guessing it's:
>
> point = getCursorInfo(dcmObj);
>
> If so, do you have the MATLAB DSP System Toolbox installed?
> It is required for the getCursorInfo command.

There is an object in DSP System Toolbox, dsp.LogicAnalyzer, that has a
getCursorInfo method.

http://www.mathworks.com/help/dsp/ref/dsp.logicanalyzer.getcursorinfo.html

The datacursormode object returned by the DATACURSOR function also has a
getCursorInfo method. See the "Querying Data Cursor Mode" section on the
documentation page.

http://www.mathworks.com/help/matlab/ref/datacursormode.html

The error message is likely coming from the next line, where the OP tries to
get the Position from the data cursor info struct. If there are no data
cursors then the datacursormode object's getCursorInfo method will return
[]. For consistency (always returning a 1-by-numberOfDataCursors struct
array) it probably should return a 1-by-0 struct array instead; I will ask
the development team about that.

To block until the user actually creates a data cursor (rather than blocking
until the user clicks in the figure, which may not be a click on a graphics
object in the axes) try this:

plot(1:10);
D = datacursormode;
while isempty(getCursorInfo(D))
    waitforbuttonpress;
end
infoStruct = getCursorInfo(D)

Replace the ISEMPTY call with "numel(getCursorInfo(D)) < N" to block until
the user creates N data cursors.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Viewing all articles
Browse latest Browse all 25

Latest Images

Trending Articles


Telangana Ration Card Online Status Ahara Bhadratha Card Online Status


CalCen


Waves Complete v2019.02.14 Incl Emulator-R2R


[RELEASE THREAD]--_A-Team_--Cricket_Dream_5G


MCGEE, SAMUEL O., DECEASED, OF...


WordPress: Reverse Shell


GPGT - chio bu back from market kym


Ondonga king dragged to court


Justin Guy Ballou, III


Krupt Biography, Death, Songs, Photo, Video



Latest Images