can you help me solve this error?

hey, Im new in this community and this error keep on popping up
Im in need of your help!!
Dot indexing is not supported for variables of this type.
Error in MAGNETORQUER>get_Callback (line 274)
if (length(ud.Data) == 10)
this is the part of the code :
if (length(ud.Data) == 10)
%Acceleration in m/s2
Ax=ud.Data(1)/AccelScaleFactor*9.81 ;
Ay=ud.Data(2)/AccelScaleFactor*9.81;
Az=ud.Data(3)/AccelScaleFactor*9.81;
%Angular speed in deg/s
Gx=ud.Data(5)/GyroScaleFactor;
Gy=ud.Data(6)/GyroScaleFactor;
Gz=ud.Data(7)/GyroScaleFactor;
%Magnetometer data in uT
mx=ud.Data(8)/MagnetScaleFactor;
my=ud.Data(9)/MagnetScaleFactor;
mz=ud.Data(10)/MagnetScaleFactor;
set(handles.axeX,'string',num2str(mx,3));
set(handles.axeY,'string',num2str(my,3));
set(handles.axeZ,'string',num2str(mz,3));
set(handles.dipoleX,'string',num2str(Gxx,3));
set(handles.dipoleY,'string',num2str(Gyy,3));
set(handles.dipoleZ,'string',num2str(Gzz,3));
set(handles.bex,'string',num2str(Ax,3));
set(handles.bey,'string',num2str(Ay,3));
set(handles.bez,'string',num2str(Az,3));

Respuestas (1)

Andreas Goser
Andreas Goser el 9 de Mayo de 2023

0 votos

Dot indexing is a way of accessing data fields in MATLAB structs. The question now is: Is your variable ud a struct? Can you let us know what ud is?

4 comentarios

9L_peek
9L_peek el 9 de Mayo de 2023
Yes its a structure of 10 bits
Walter Roberson
Walter Roberson el 9 de Mayo de 2023
At the point of the error, it is not a struct. It is probably empty. Is this part of a loop?
9L_peek
9L_peek el 9 de Mayo de 2023
Yes its a part of a while loop Its a data retrieving loop from 2 sensors mpu6050 and a magnetometer
At some point, either at the beginning or after operating for a while, ud is not a struct.
Use
dbstop if error
and run your code and examine ud at the time of the problem.

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Versión

R2023a

Etiquetas

Preguntada:

el 9 de Mayo de 2023

Comentada:

el 9 de Mayo de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by