フィルターのクリア

Invalid file identifier in Parfor loop

1 回表示 (過去 30 日間)
xiaohuo
xiaohuo 2022 年 3 月 10 日
コメント済み: xiaohuo 2022 年 3 月 11 日
How to correct this error when using the parfor loop? Any suggestion to solve this issue? Thanks.
Invalid file identifier. Use fopen to generate a valid file identifier.
filename01 = "D:\...\testParfor"; % filename01 file parth
parfor j = 1:nk2_node
% File path
filename_HD = sprintf('%s%s%d',filename01,"\zone_case0\profile_",j);
Cal_cont = HD_Nod_Inf(filename_HD);
...
end
  9 件のコメント
Walter Roberson
Walter Roberson 2022 年 3 月 11 日
for i=1:199
k = i + Line_nod_sub-1-199;
Cal_cont(i,1:22) = str2num(newtline_Nod_sub{k}); % error
end
Suppose that 50 lines were read, so Line_nod_sub = 50. First iteration of the loop, i is 1, and k = 1 + 50 - 1 - 199 which is 51-200 which is -149 . Out of range.
Suppose that 205 lines were read, so Line_nod_sub = 205. First iteration of the loop, i is 1, and k = 1 + 205-1-199 = 6, which is okay. Last iteration of the loop, i is 199, and k = 199 + 205 - 1 - 199 = 204, which looks okay.
So I guess your loop might be okay -- but not until after you enforce that Line_nod_sub is at least 200.
xiaohuo
xiaohuo 2022 年 3 月 11 日
Yes, I also think so.
The reason why the code does not work is that the exe fails to run the model. So there is no output values in that file.
Thanks for your help and time.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeUse COM Objects in MATLAB についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by