Unrecognized function or variable 'RESB'.

1 回表示 (過去 30 日間)
Federico Paolucci
Federico Paolucci 2022 年 7 月 27 日
回答済み: Walter Roberson 2022 年 7 月 27 日
Hi, this errors are occurred:
Warning: Function input has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.
reader_pf
21 for i=1:length(a)
Unrecognized function or variable 'RESB'.
Error in reader_pf (line 35)
for i=1:length(RESB)
this is the script of the function reader_pf
function [RES]=reader_pf(~);
% pulisce il file ANSYS dei fattori di partecipazione
%
% INPUT
% file nome del file ANSYS
% cleaned_file nome del file pulito
%
% OUTPUT
% RES matrice dei fattori di partecipazione
fid1=fopen("pffe.mat");
C = textscan(fid1,'%s');
fclose(fid1);
a=C{1};
%A=[a{1}];
%b=strcmp(A,'NOTE');
%C=strcmp(A,'NO.');
%k=0;
%kk=k;
for i=1:length(a)
A=[a{i}];
B=strcmp(A,'NOTE');
C=strcmp(A,'NO.');
if B==1
k1=k+1;
RESB(k1)=i;
end
if C==1
kk1=kk+1;
RESC(kk1)=i;
end
end
for i=1:length(RESB)
BB{i}=a(RESC(i)+10:RESB(i)-2);
end
for i=1:k
a=BB{z};
la=length(a);
for j=1:la-4
A=[a{j+4}];
X(j,i)=str2num(A);
end
end
RES=[X(1:2:end,1) X(2:2:end,:)];
save(cleaned_file, 'RES', '-ascii')

採用された回答

Walter Roberson
Walter Roberson 2022 年 7 月 27 日
fid1=fopen("pffe.mat");
C = textscan(fid1,'%s');
You are opening a .mat file, and trying to read a string from the beginning of the file. What happens if the .mat file has no string there? Then C{1} will be empty, and length(a) will be 0.
You need to have pretty good reasons to use fopen() with a .mat file, as .mat files are binary files, not text files. You would need to have studied the documentation on the internal structure of .mat files before you can meaningfully read data from a .mat file.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by