Error using fgets Invalid file identifier. Use fopen to generate a valid file identifier.
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
CODE
clear all; close all; clc
addpath('apm')
s = 'http://byu.apmonitor.com';
a = 'data_regression';
apm(s,a,'clear all');
apm_load(s,a,'model.apm');
csv_load(s,a,'data.csv');
apm_info(s,a,'FV','a');
apm_info(s,a,'FV','b');
apm_info(s,a,'FV','c');
apm_option(s,a,'a.status','1');
apm_option(s,a,'b.status','1');
apm_option(s,a,'c.status','1');
apm_option(s,a,'nlc.imode',2);
output = apm(s,a,'solve');
disp(output)
ERROR
Error using fgets
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in apm_load (line 21)
aline = fgets(fid);
Error in Regression (line 10)
apm_load(s,a,'model.apm');
2 comentarios
Adam Danz
el 4 de En. de 2023
Please share the code that generates the fid variable and share the value of fid.
Voss
el 4 de En. de 2023
@Adedotun Banjo: Are you using this File Exchange entry?
Respuestas (1)
Voss
el 4 de En. de 2023
Specify the file names as absolute or relative path names. That is, instead of specifying just the file name "model.apm", if "model.apm" is located in the "apm" directory, which is in the current working directory, you could say:
model_file_name = fullfile('.','apm','model.apm');
apm_load(s,a,model_file_name);
That's a relative path (relative to the current working directory). You could also use an absolute path, e.g.:
model_file_name = 'C:\Users\banjo\apm\model.apm'; % or wherever model.apm is on your computer
apm_load(s,a,model_file_name);
Similarly for other file names you need to specify.
0 comentarios
Ver también
Categorías
Más información sobre File Operations 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!