Need help on using trapz on a definite integral
Show older comments
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)
Alan Stevens
on 4 Jul 2021
Replace
Final = Nach + Vor;
by
Final(i) = Nach + Vor;
6 Comments
md mayeen uddin
on 4 Jul 2021
Edited: md mayeen uddin
on 4 Jul 2021
Alan Stevens
on 4 Jul 2021
I can't test your code as you haven't supplied all the data: e.g.Kfm, h1, h0 etc.
md mayeen uddin
on 4 Jul 2021
Edited: md mayeen uddin
on 4 Jul 2021
Alan Stevens
on 4 Jul 2021
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).
md mayeen uddin
on 4 Jul 2021
Alan Stevens
on 5 Jul 2021
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.
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!