error dot indexing

General forum for EasySpin: questions, how to's, etc.
Post Reply
ranjana1
Newbie
Posts: 3
Joined: Sun Mar 06, 2022 3:15 pm

error dot indexing

Post by ranjana1 »

Hello,
I am trying to use esfit feature of EasySpIn in my spectra simulation.
When I tried to entry variable feature in following way,
Vary.A = [1 3 2]
it constantly gives me this error:

'Unable to perform assignment because dot indexing is not supported
for variables of this type'

What would be the way to enter the varying parameters?
I will greatly appreciate your input
Ranjana

DanielKlose
User
Posts: 18
Joined: Thu Jun 09, 2022 5:22 am

Re: error dot indexing

Post by DanielKlose »

Dear Ranjana,

it sounds to me as if your Vary variable is already assigned to a type other than struct before you execute that line of code.
You could add either "clear Vary;" or "Vary = struct()"; before to remove the previous assignment.
Otherwise, please consider posting more information such that we can help based on your code - if still needed ;)
Best wishes!

ykliao
User
Posts: 15
Joined: Sun Jun 20, 2021 11:56 pm

Re: error dot indexing

Post by ykliao »

I have one question related to this topic. I'm more used to assign structures as

Code: Select all

Vary = struct('abc', 123);

With this I can avoid situations like the variable has been assigned to something else before. Or I can also avoid having conflicting fields in one structure.

For instance, when I am assessing between gStrain and DStrain, if I don't specifically remove the structure then re-assign it but simply changing sys.gStrain to sys.DStrain. Both fields will be written in the structure and can cause error.

Meanwhile, I see people always do dot indexing. I wonder what's the pros and cons between these two methods. Is there anything that might significantly slow down the program or cause other problems? (like taking more space in the memory or those kind of issue)

Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: error dot indexing

Post by Stefan Stoll »

The dot syntax is a bit more readable in my opinion than struct with lots of name-value arguments.

To make sure you start with an empty structure when using the dot syntax, start with Sys = struct;. This initializes Sys to an empty structure without any fields.

Post Reply