Error using fgets Invalid file identifier. Use fopen to generate a valid file identifier.
3 ビュー (過去 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');
2 件のコメント
Adam Danz
2023 年 1 月 4 日
Please share the code that generates the fid variable and share the value of fid.
Voss
2023 年 1 月 4 日
@Adedotun Banjo: Are you using this File Exchange entry?
回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!