Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a 1xN structure? #6

Open
maryambrosino opened this issue May 24, 2022 · 6 comments
Open

How to create a 1xN structure? #6

maryambrosino opened this issue May 24, 2022 · 6 comments

Comments

@maryambrosino
Copy link

Hello everyone.
I would like to create a struct with size 1xN.

For example:
field1 field2
A 1
B 2
C 3
D 4
... ....

Which TinyMAt functions (or combination of them) can I use ?

@jkriege2
Copy link
Owner

You could use TinyMATWriter_writeMatrix2D_colmajor() ... see http://jkriege2.github.io/TinyMAT/group__tinymatwriter.html#ga710d61be33f483e62fe187c06bad5e38

@jkriege2
Copy link
Owner

Did it work for you? Can I close this issue?

@maryambrosino
Copy link
Author

maryambrosino commented May 28, 2022 via email

@jkriege2
Copy link
Owner

Hmmm ... let's see ... I think there are two options for that ... if I understand correctly:

  1. There is a simple interface to write structs:
std::map<std::string, double> mp1;		
mp1["x"]=100;		
mp1["y"]=200;		
mp1["z"]=300;		
mp1["longname"]=10000*M_PI;		TinyMATWriter_writeStruct(mat, "struct1", mp1);		

This creates a struct with fields that contain one double each ... so this is very limited.
3. There is a low-level interface for structs that is very flexible:

TinyMATWriter_startStruct(mat, "struct1");
// ... use all other instructions here ... variables will be put as fields into the struct 
//... you can also use another start/endStruct pair to nest structs
TinyMATWriter_endStruct(mat);

There is also a similar interface for cell arrays ...

Does this help? If so, I can look for a better example and update the documentation within the next 1-2 weeks

@maryambrosino
Copy link
Author

maryambrosino commented May 30, 2022 via email

@ANQSL
Copy link

ANQSL commented Apr 7, 2023

hello , Do you have solved this problem. if you always solve it. Can you tell me how you to do? Thanks @maryambrosino

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants