Error using fgets Invalid file identifier. Use fopen to generate a valid file identifier.

4 次查看(过去 30 天)
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');

回答(1 个)

Voss
Voss 2023-1-4
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.

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by