# Need help on using trapz on a definite integral

조회 수: 2(최근 30일)
md mayeen uddin 2021년 7월 4일
댓글: Alan Stevens 2021년 7월 5일
meu = 0.01; % acting friction during rolling
kfm= Kfm(1:end,:); % kfm values for all passes
h_1 = h1(1:end,:); % height after reduction
h_0 = h0(1:end,:); % initial height
Delta_h = abs(h_1 - h_0); % relative height reduction
l_d = sqrt(Radius_R*Delta_h); % bite length
initX1 = 0; % bite angle at initial position
Xf = (tspan(rowOfMinValue))'; % bite angle at position Xf 1x201
Lenxf = length(Xf);
X_ld= l_d(1,1); % 1x1 element of xf
SigNach = y(:,1); % 11953x1 back tension
SigVOR = SigV; % 11953x201 front tension
for i = 1:Lenxf
%vRange for the first integration
R1 = initX1 : Xf(i,1);
% for the first integration the constant value is
int1 = SigNach -kfm(1,1);
% Range for the 2nd integration
R2 = Xf(i,1) :X_ld;
% constant for the second integration constant value is
int2 = SigVOR -kfm(1,1);
% first integration
Nach = trapz(R1,int1);
% second integration
Vor = trapz(R2,int1);
%
Final = Nach + Vor;
end
\\\ First of there is something wrong with dimentions in my code (i am beginner). i want to store the {Final = Nach + Vor;} for every values of x_f in a column.\\\\\

댓글을 달려면 로그인하십시오.

### 답변(1개)

Alan Stevens 2021년 7월 4일
Replace
Final = Nach + Vor;
by
Final(i) = Nach + Vor;
##### 댓글 수: 6표시숨기기 이전 댓글 수: 5
Alan Stevens 2021년 7월 5일
What does this mean:
Xf = (tspan(rowOfMinValue))';
What is rowOfMinValue? Have you defined a function called tspan?
What is y in:
SigNach = y(:,1);
Even when I loaded your data into memory these problems arose! I'm still nowhere near getting to the point of identifying a trapz problem!
You could help us help you by making it easier to run your program. Get it to load the (reduced amount of) data with the appropriate variable names first and then upload the whole program.

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!