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 CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by