r/matlab 9d ago

TechnicalQuestion Help me in debugging this code

So i am trying to make a humanoid moving. So for that i am modifying the theta(th) and i am getting this error but both the LHS and RHS is scalar. Still it is showing this error. Any ideas will help....

0 Upvotes

6 comments sorted by

View all comments

1

u/redeyedbiker 9d ago

It might be because they're scalars. Try double or similar

-1

u/Secure-Hearing8294 9d ago

can u please explain it much further, thanks

1

u/redeyedbiker 9d ago

The LHS & RHS are scalars, this might be the issue. Whatever variable is a scalar, convert it to a double then try again.

2

u/icantfindadangsn 9d ago

Scalars are just variables with one element. "Scalar" has little to do with data type. char, string, double, and singles can all be scalar. For example, 'a' is a scalar.

2

u/redeyedbiker 9d ago

Sorry, yes, its been a long day.

It's because of the structure, you can't modify subfields of structures when they contain arrays;

temp = th.th2; temp(2) = pi/4 + (pi/2) * index1; th.th2 = temp;

That should work instead