Reading the data from one m file in another m file
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey guys,
I would like to create two functions:
function model = CreateModel()
function sol=CreateRandModel(model)
In the function CreateModel I'd like to include all the informations about the model, It should be a structure with Matrix m (which is read from the csv file), times t1-t4 generated by myself and some interpolation data y1-y50 (in total structure with 55 fields)
I wrote a code:
function model = CreateModel()
%reading the data
%reading all parameters (t,interpolations....)
m=readtable('Fuel_arrivaltime.csv');
t1 = 0.7:0.01:0.85;
t2 = 0.72:0.01:0.86;
t3 = 0.68:0.01:0.83;
t4 = 0.70:0.01:0.86;
and the y: from y1 till y2 are described with the interpolation functions:
y1 = interp1(m.AFR256(2:7),m.AFR256_1(2:7),t1,'linear');
y2 = interp1(m.AFR256(2:7),m.AFR256_2(2:7),t1,'linear');
etc.
But the problem is that I don't know how to code it properly to make it readable in another m.file (function sol=CreateRandModel(model)) - where the input data should be the data from the model.
at the end of the
function model = CreateModel() I wrote:
model.m=m;
model.t1=t1;
model.t2=t2;
model.t3=t3;
model.t4=t4;
model.y1=y1;
model.y2=y2;
etc.
and at the beginning of the
function sol=CreateRandModel(model)
t1=model.t1;
t2=model.t2;
t3=model.t3;
t4=model.t4;
y1=model.y1;
y2=model.y2;
But after compilation it shows that there is not enough input arguments, I feel like the second file can't read the informations from the first one.
0 comentarios
Respuestas (1)
Voss
el 30 de Abr. de 2022
Maybe you need to call CreateRandModel at the end of CreateModel?
function model = CreateModel()
% ...
model.m=m;
model.t1=t1;
model.t2=t2;
model.t3=t3;
model.t4=t4;
model.y1=y1;
model.y2=y2;
% ...
CreateRandModel(model)
and maybe do something with the output from CreateRandModel too.
0 comentarios
Ver también
Categorías
Más información sobre Data Import and Analysis 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!