write into row 2 columne 10 of a structure a value in matlab

Suppose you have a structure myStruct which has multiple fields and you want to write a value to row 2 column 10 of one of those fields. You can achieve this using the following code:

main.m
myStruct.fieldName(2,10) = <your_value>;
41 chars
2 lines

Replace fieldName with the actual name of your field and <your_value> with the value you want to assign to that specific location of the field.

Note that this only works if the field is a numeric array or a cell array. If the field is a character array, you can use a similar approach but with curly braces:

main.m
myStruct.fieldName{2,10} = '<your_string>';
44 chars
2 lines

Again, replace fieldName with the actual name of your field and <your_string> with the string you want to assign to that specific location of the field.

related categories

gistlibby LogSnag