Borrar filtros
Borrar filtros

How to write a value of type double(vector) into a cell in a struct

1 visualización (últimos 30 días)
H = setfield(H, {1,5}, 'SOC', {1} ,0.8)%I wanted to write value into H(1).SOC in the first cell of field SOC in H(struct)
H(1).SOC{1,1} = 0.8 %I used these two statements but I wasnt able to write values into H(1).SOC vector
%Please suggest me how to write values into SOC(for four rows) of
%H(struct).
%Thanks in advance

Respuesta aceptada

Image Analyst
Image Analyst el 23 de Sept. de 2021
Editada: Image Analyst el 23 de Sept. de 2021
Do you mean like this:
% Make sample H structure array.
for k = 1 : 7
for col = 1 : 3
for row = 1 : 4
H(k).SOC{row, col} = rand
end
end
end
H
% Now we have an H and we can begin.
% Take the first structure, H(1), and make the SOC field of it be a cell with 0.8 in it rather than the original array.
H(1).SOC(:) = {0.8}
If not, show what you'd like for H in the output.

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by