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

3 ビュー (過去 30 日間)
Adeb
Adeb 2023 年 1 月 4 日
回答済み: Voss 2023 年 1 月 4 日
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 Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by