How to add a new array in the structure?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Muhammad Qaisar Fahim
el 11 de Ag. de 2021
Comentada: Yazan
el 12 de Ag. de 2021
Let say I have this structure ( vehicle.genset_model) where inside this structure I have vehicle.genset_model.drag=[4;5;6;7;8;9;10]. This file is saved as mat file. In this file I want to create a new array that should be in the same structure (vehicle.genset_model) but with the extension temperature i.e., vehicle.genset_model.Temperature=[25;28;31;34;37;40;43]
0 comentarios
Respuesta aceptada
Yazan
el 11 de Ag. de 2021
clc, clear
vehicle.genset_model.drag = [4; 5; 6; 7; 8; 9; 10];
% save structure array in 'data.mat'
save('data.mat', 'vehicle');
clear
% load data.mat
load('data.mat');
% add a new field
vehicle.genset_model.Temperature = [25; 28; 31; 34; 37; 40; 43];
% save new structure array
save('data.mat', 'vehicle');
clear
2 comentarios
Yazan
el 12 de Ag. de 2021
On which line, you get this error? The code is pretty simple and it works.
Más respuestas (0)
Ver también
Categorías
Más información sobre Entering Commands 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!