How can I save structures in a specific folder? Thank you.
5 Answers
0
To specify a specific folder, you just need to add the full path to your savestruct call. For example:
struct DS my_ds_struct; my_ds_struct = dsCreate(); my_ds_struct.dataMatrix = pi .* ones(4, 1); ret = savestruct(my_ds_struct, "C:\\gauss\\data\\my_ds_struct");
If you will be saving and loading much data to this location it is a good practice to create a variable that contains the path and then use the string combination operator ($+) to add the file name on the end, like this:
data_path = "C:\\gauss\\data\\"; struct DS my_ds_struct; my_ds_struct = dsCreate(); my_ds_struct.dataMatrix = pi .* ones(4, 1); ret = savestruct(my_ds_struct, data_path$+"my_ds_struct");
0
Ok, got it.
I was working with another type of structure, not the DS structure, and I save it in the disk as following:
struct Value_Structure6 { matrix V_M_su_l; }; struct Value_Structure_Array6 { array V_M_su_l; }; //Declare structure instance struct Value_Structure6 V6; // Initialize Value Functions V6.V_M_su_l=V_M_su_l; data_path = "D:\\Data_out\\"; ret = savestruct(V6, data_path$+"V.668");
Now, I´m facing some difficulties loading this structure. In the help said that I need something like:
#include ds.sdf; struct DS p3; { p3, retc } = loadstruct("p2", "ds");
Now I realize than I could open the structure if I repeat the lines above and then I use loadstruct, I just want to understand why.
struct Value_Structure6 { matrix V_M_su_l; }; struct Value_Structure_Array6 { array V_M_su_l; }; //Declare structure instance struct Value_Structure6 V6; struct Value_Structure6 V6; { V6, retc } = loadstruct("V.CPS_U2","Value_Structure6");
0
It looks like the end of your question may have been cut off. However, I think this example will show you what you are looking to do.
struct Value_Structure6 { matrix V_M_su_l; }; struct Value_Structure_Array6 { array V_M_su_l; }; //Declare structure instance struct Value_Structure6 V6; // Initialize Value Functions V6.V_M_su_l=V_M_su_l; data_path = "D:\\Data_out\\"; ret = savestruct(V6, data_path$+"V.668"); //Declare new structure instance struct Value_Structure6 V6_new; { V6_new, ret } = loadstruct(data_path$+"V.668", "Value_Structure6");
0
Yes, I just want to understand about the DS structure I don´t understand exactly what is it doing.
0
I am sorry. I misunderstood your question. Is your question just generally about what the DS structure is and how to use it? Or is your question about what is happening with the DS structure in the example you pasted?
Your Answer
5 Answers
To specify a specific folder, you just need to add the full path to your savestruct call. For example:
struct DS my_ds_struct; my_ds_struct = dsCreate(); my_ds_struct.dataMatrix = pi .* ones(4, 1); ret = savestruct(my_ds_struct, "C:\\gauss\\data\\my_ds_struct");
If you will be saving and loading much data to this location it is a good practice to create a variable that contains the path and then use the string combination operator ($+) to add the file name on the end, like this:
data_path = "C:\\gauss\\data\\"; struct DS my_ds_struct; my_ds_struct = dsCreate(); my_ds_struct.dataMatrix = pi .* ones(4, 1); ret = savestruct(my_ds_struct, data_path$+"my_ds_struct");
Ok, got it.
I was working with another type of structure, not the DS structure, and I save it in the disk as following:
struct Value_Structure6 { matrix V_M_su_l; }; struct Value_Structure_Array6 { array V_M_su_l; }; //Declare structure instance struct Value_Structure6 V6; // Initialize Value Functions V6.V_M_su_l=V_M_su_l; data_path = "D:\\Data_out\\"; ret = savestruct(V6, data_path$+"V.668");
Now, I´m facing some difficulties loading this structure. In the help said that I need something like:
#include ds.sdf; struct DS p3; { p3, retc } = loadstruct("p2", "ds");
Now I realize than I could open the structure if I repeat the lines above and then I use loadstruct, I just want to understand why.
struct Value_Structure6 { matrix V_M_su_l; }; struct Value_Structure_Array6 { array V_M_su_l; }; //Declare structure instance struct Value_Structure6 V6; struct Value_Structure6 V6; { V6, retc } = loadstruct("V.CPS_U2","Value_Structure6");
It looks like the end of your question may have been cut off. However, I think this example will show you what you are looking to do.
struct Value_Structure6 { matrix V_M_su_l; }; struct Value_Structure_Array6 { array V_M_su_l; }; //Declare structure instance struct Value_Structure6 V6; // Initialize Value Functions V6.V_M_su_l=V_M_su_l; data_path = "D:\\Data_out\\"; ret = savestruct(V6, data_path$+"V.668"); //Declare new structure instance struct Value_Structure6 V6_new; { V6_new, ret } = loadstruct(data_path$+"V.668", "Value_Structure6");
Yes, I just want to understand about the DS structure I don´t understand exactly what is it doing.
I am sorry. I misunderstood your question. Is your question just generally about what the DS structure is and how to use it? Or is your question about what is happening with the DS structure in the example you pasted?