structure

Matlab: adding value into initialized nested struct-cell

 ̄綄美尐妖づ 提交于 2019-11-30 17:33:54
问题 I have this structure Data = struct('trials',{},'time',{},'theta_des',{},'vel_des',{},'trials_number',{},'sample_numbers',{}); Data(1).trials = cell(1,trials_number); for i=1:trials_number Data.trials{i} = struct('theta',{},'pos_err',{},'vel',{},'vel_err',{},'f_uparm',{},'f_forearm',{},'m_uparm',{},'m_forearm',{},... 'current',{},'total_current',{},'control_output',{},'feedback',{},'feedforward',{},'kp',{}); end but when I want to add a value Data.trials{i}.theta = 27; I get this error... A

When to use a union and when to use a structure

爱⌒轻易说出口 提交于 2019-11-30 15:19:57
I know the differences between union and structure. But from a design and coding perspective what are the various use cases of using a union instead of a structure? One is a space optimization. Are there any more advantages of using them? There's really only two major uses. The first is to create a discriminated union. That's probably what you were thinking of by "space optimization," but there's a bit more to it. You need an extra bit of data to know which member of the union is "alive" (has valid data in it) since the compiler does not do this for you. You'd usually see code like that having

What is the purpose of gradle's buildSrc folder?

孤者浪人 提交于 2019-11-30 14:35:19
问题 In gradle, what is the purpose of using a buildSrc file as a top level, as opposed to just a typical java project layout (src/main/java)? If I have a layout of src main java or buildSrc src main java What would be the difference (or the reason for doing this)? Is it more useful in multi module projects? Even for a multi module project, couldn't I do something like proj1 src proj2 src And then just have a top level build.gradle (at the same level as proj1 and proj2 ) that defines common

Marshall array of structures

喜欢而已 提交于 2019-11-30 12:25:44
I've spent a lot of time to look for the solution but still don't find it out. I have 2 classes: [StructLayout(LayoutKind.Sequential)] public class Result { public int Number; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] public string Name; public int Size; } [StructLayout(LayoutKind.Sequential)] public class CoverObject { public int NumOfResults; [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 4)] public Result[] Results; } My expectation that the command Marshal.SizeOf(typeof(CoverObject)) will return 52, but not, it's just 20. Thus, all of

How can I learn to write well-structured programs in Perl? [closed]

两盒软妹~` 提交于 2019-11-30 12:09:12
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I've started learning Perl but most of my former programming experience has been in languages that emphasize object oriented programming such as C# and Java. All the Perl examples I have found tend to be long single function programs and I find my self writing code the same way. Are there any resources or

why padding is not happening in this case?

纵然是瞬间 提交于 2019-11-30 10:41:51
问题 As per my knowledge, By default 4-byte alignment will be done. say typedef struct { int data7; unsigned char data8; //3 -bytes will be added here. }Sample1; so sizeof(Sample1) will be 8. But for the following structure, why padding is not happened?. typedef struct { unsigned char data1; unsigned char data2; unsigned char data3; unsigned char data4; unsigned char data5; unsigned char data6; }Sample2; But the sizeof(Sample2) is 6 only. This Sample2 is not a 4 byte aligned structure? EDIT:: As

Best practice for storing tags in a database?

孤人 提交于 2019-11-30 10:39:36
问题 I developed a site that uses tags (key words) in order to categorize photographs. Right now, what I have in my MySQL database is a table with the following structure: image_id (int) tag (varchar(32)) Every time someone tags an image (if the tag is valid and has enough votes) it's added to the database. I think that this isn't the optimal way of doing things since now that I have 5000+ images with tags, the tags table has over 40000 entries. I fear that this will begin to affect performance

Where should utility functions live in Django?

烂漫一生 提交于 2019-11-30 10:33:27
问题 Where should utility functions live in Django? Functions like custom encrypting/decrypting a number, sending tweets, sending email, verifying object ownership, custom input validation, etc. Repetitive and custom stuff that I use in a number of places in my app. I'm definitely breaking DRY right now. I saw some demos where functions were defined in models.py, although that didn't seem conceptually right to me. Should they go in a "utilities" app that gets imported into my project? If so, where

how to convert the Certificate String into X509 structure.?

假装没事ソ 提交于 2019-11-30 08:53:05
can any one tell me how to convert the string content into X509 structure . i am using openssl to read the X509 Structure. example : certificate string -----BEGIN CERTIFICATE----- MIIExDCCA6ygAwIBAgIJAK0JmDc/YXWsMA0GCSqGSIb3DQEBBQUAMIGcMQswCQYD VQQGEwJJTjELMAkGA1UECBMCQVAxDDAKBgNVBAcTA0hZRDEZMBcGA1UEChMQUm9j a3dlbGwgY29sbGluczEcMBoGA1UECxMTSW5kaWEgRGVzaWduIENlbnRlcjEOMAwG A1UEAxMFSU1BQ1MxKTAnBgkqhkiG9w0BCQEWGmJyYWphbkBSb2Nrd2VsbGNvbGxp bnMuY29tMB4XDTExMDYxNjE0MTQyM1oXDTEyMDYxNTE0MTQyM1owgZwxCzAJBgNV BAYTAklOMQswCQYDVQQIEwJBUDEMMAoGA1UEBxMDSFlEMRkwFwYDVQQKExBSb2Nr

Multiple Exits From F# Function

孤者浪人 提交于 2019-11-30 08:45:00
I could do this easily in C++ (note: I didn't test this for correctness--it's only to illustrate what I'm trying to do): const int BadParam = -1; const int Success = 0; int MyFunc(int param) { if(param < 0) { return BadParam; } //normal processing return Success; } But I cannot figure out how to exit a routine early in F#. What I want to do is to exit the function on a bad input but continue if the input is ok. Am I missing some fundamental property of F# or am I approaching the problem in the wrong way since I'm just learning FP? Is a failwith my only option here? This is what I've got so far