Need help on using trapz on a definite integral

meu = 0.01; % acting friction during rolling
Radius_R = 21; % Radious of the roll die
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.\\\\\

Answers (1)

Replace
Final = Nach + Vor;
by
Final(i) = Nach + Vor;

6 Comments

i am still getting error and the error messeges are below
Error using trapz (line 66)
Point spacing must be a scalar specifying uniform spacing or a vector of x-coordinates for each data point.
Error in ForceCalculation (line 31)
Vor = trapz(R2,int1);
I can't test your code as you haven't supplied all the data: e.g.Kfm, h1, h0 etc.
file for SIgV is too big (11953x201). i tried several times to upload it and failed .the others are here
Try uploading a reduced set of values. Say 100 rows and 10 columns. Enough to test the process. (Make sure the other data sets are correspondingly smaller where appropriate).
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.

Sign in to comment.

Asked:

on 4 Jul 2021

Commented:

on 5 Jul 2021

Community Treasure Hunt

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

Start Hunting!