Unrecognized function or variable 'RESB'.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Federico Paolucci
am 27 Jul. 2022
Beantwortet: Walter Roberson
am 27 Jul. 2022
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')
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 27 Jul. 2022
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!