Unrecognized function or variable 'RESB'.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Federico Paolucci
il 27 Lug 2022
Risposto: Walter Roberson
il 27 Lug 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 Commenti
Risposta accettata
Walter Roberson
il 27 Lug 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!