1

enter image description here

As you can see in the picture, I have three variables, two are named number_of_steps_... and the third one is struct.

How can I save the content saved in the number_of_steps variables into struct?

I have tried the save command but that doesn't work for what I need. What is the right way to do this?

Suever
  • 64,497
  • 14
  • 82
  • 101
john.steak
  • 59
  • 9

1 Answers1

0

I don't know what you mean by "save", but you can add them to the struct by using

mystruct.number_of_steps1 = number_of_steps1
mystruct.number_of_steps2 = number_of_steps2

Then save the struct to a file using

save mystruct.mat mystruct

Notice I've taken the liberty of renaming the variable struct as mystruct. Since "struct" is a Matlab command, it's not a good idea to use it as a variable name.

Wolfie
  • 27,562
  • 7
  • 28
  • 55
  • I need to get the data from variables NUMBER_OF_STEPS1 and NUMBER_OF_STEPS2 and save it insiade the STRUCT/MYSTRUCT – john.steak Apr 05 '17 at 08:22
  • You mean "save" as in they are stored within the struct variable, or as in saved as a file on your computer? Have you tried the above lines of code? Use backticks (`, next to the 1 on your keyboard) to format stuff as code, instead of needing all caps... – Wolfie Apr 05 '17 at 08:35
  • 1
    I have in workspace structural variable 'struct' which contains nine other variables and I want to get 'number_of_steps_left_foot' and 'number_of_steps_right_foot' to the 'struct' ..so after 'struct' will contain 9 variables + 'number_of_steps_left_foot' and 'number_of_steps_right_foot' – john.steak Apr 05 '17 at 08:49
  • Works perfectly! Thank you! – john.steak Apr 05 '17 at 09:49