Unrecognized function or variable 'RESB'.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Federico Paolucci
le 27 Juil 2022
Réponse apportée : Walter Roberson
le 27 Juil 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 commentaires
Réponse acceptée
Walter Roberson
le 27 Juil 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!