matlab problem

2 次查看(过去 30 天)
AMAL OUNARA
AMAL OUNARA 2011-5-19
hello iam new in matlab i have this question: i have ths code to calculate the error between two curves :
function b = fonct(lam)
global Uexp RFexp
%lecture des données expérimentaux
fid =fopen('données expérimentaux.m','r');
M = fscanf(fid,'%e',[1,1]);
xy=fscanf(fid,'%e%e',[2,M]);
xy1=xy';
Uexp=xy1(:,1); %vesteur colonne U2- déplacement
RFexp=xy1(:,2); %vecteur colonne RF2- réaction
mef(lam);
rf4;
Fint=interp1(Uexp,RFexp,-c(:,3),'spline');
b=0;
for i=1:108
X=Fint((i)-RFexp(i)).^2
b=b+X
end
b after runnig it give me this error:
??? Attempted to access Fint(1.99984); index must be a positive integer or logical.
Error in ==> fonct at 16 X=Fint((i)-RFexp(i)).^2 can anyone help me thanks a lot

采纳的回答

Franck Dernoncourt
Franck Dernoncourt 2011-5-19
You probably meant "X=(Fint(i)-RFexp(i)).^2".

更多回答(2 个)

AMAL OUNARA
AMAL OUNARA 2011-5-19
thanks a lottttttttt it really works now wonderful
good luck

AMAL OUNARA
AMAL OUNARA 2011-5-19
hi i have also the same problem when i ake this code : function b = fonct(lam)
global Uexp RFexp
%lecture des données expérimentaux
fid =fopen('données expérimentaux.m','r');
M = fscanf(fid,'%e',[1,1]);
xy=fscanf(fid,'%e%e',[2,M]);
xy1=xy';
Uexp=xy1(:,1); %vesteur colonne U2- déplacement
RFexp=xy1(:,2); %vecteur colonne RF2- réaction
mef(lam);
rf4;
Fint=interp1(Uexp,RFexp,-c(:,3),'spline');
Fsim= - c(:,5);
b=0;
for i=1:45
X=(Fint(i)-Fsim(i)).^2;
b=b+X
end
b
both Fint and Fsim are arrays contains 45 value but the error is :
??? Attempted to access Fint(42); index out of bounds because numel(Fint)=41.
Error in ==> fonct at 17
X=(Fint(i)-Fsim(i)).^2;
what shall i do please ????

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

标签

尚未输入任何标签。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by