Hello,
I am trying to do integration of a excel data. When I try to do that I am getting an error as follows:
Error using cumtrapz (line 51)
Dimension argument must be a positive integer scalar within indexing range.
Please can someone help me in solving that .
My code:
X1 = xlsread('Abb76at104.xlsx','A1:A63');
Y1 = xlsread('Abb76at104.xlsx','B1:B63');
V = 40.020;
A1 = pi*(X1).^2;
Q1 = A1.*Y1;
Int1 = cumtrapz(A1, V);
X2 = xlsread('Abb76at104.xlsx','A64:A130');
Y2 = xlsread('Abb76at104.xlsx','B64:B130');
A2 = pi*(X2).^2;
Q2 = (A2).*40.02;
Int2 = cumtrapz(A2, V);
Thanks in advance.

 採用された回答

Mathieu NOE
Mathieu NOE 2021 年 10 月 12 日

0 投票

hello
see the doc for cumtrapz
I believe you simply put the arguments in the wrong order
it must be
Int1 = cumtrapz(V,A1);
and
Int2 = cumtrapz(V,A2);

8 件のコメント

Vishnuvardhan Naidu Tanga
Vishnuvardhan Naidu Tanga 2021 年 10 月 12 日
Thank you for the response. But I need to integrate A1 and A2 with respect to V. But not the other way around.
Mathieu NOE
Mathieu NOE 2021 年 10 月 12 日
what is V ?
this is a scalar so I take it for the x step - see documentation of cumtrapz
if you stick to your code I don't understand how you ca integrate a single scalar , the second argument of cumtrapz is the vector to integrate (and not vice versa)
Vishnuvardhan Naidu Tanga
Vishnuvardhan Naidu Tanga 2021 年 10 月 12 日
V is velocity. Is there any way to turn that scalar value to a vector?
Mathieu NOE
Mathieu NOE 2021 年 10 月 12 日
well , please explain a bit your code and the goal
what are X1 and Y1 ? how is the time increment defined ?
so far I am just guessing :
  • X1 is a radius, so A1 would be a section (area? ), Q1 is a volumetric flow (?) and you want to do a time integration of that to have a total volume in a given time interval ?
  • so what we need to do is to define the time step ; waht is the time increment in your data ?
  • why is V a scalar ?
  • also I dont understand the difference between the computation on X1, Y1 and X2, Y2 on the other side
  • I don't get why Q1 and Q2 are not computed in a similar manner :
X1 = xlsread('Abb76at104.xlsx','A1:A63');
Y1 = xlsread('Abb76at104.xlsx','B1:B63');
V = 40.020;
A1 = pi*(X1).^2;
Q1 = A1.*Y1;
Int1 = cumtrapz(V,A1);
X2 = xlsread('Abb76at104.xlsx','A64:A130');
Y2 = xlsread('Abb76at104.xlsx','B64:B130');
A2 = pi*(X2).^2;
Q2 = (A2).*40.02;
Int2 = cumtrapz(V,A2);
Vishnuvardhan Naidu Tanga
Vishnuvardhan Naidu Tanga 2021 年 10 月 12 日
Now I understood. I thought that we can do integration using a scalar. but i dont think it is possible. And Q is flowrate which i am just verifying. It makes nothing in the computation. The increment is just random. And I want to integrate the data at constant velocity. so i kept the V constant. But I think it doesnt make any sense. Thank you for clarifying.
Mathieu NOE
Mathieu NOE 2021 年 10 月 12 日
my pleasure !
if Q is your flow rate , and t is time vector or dt = time increment, you can integrate Q vs time
by doin either cumtrapz(t,Q); or cumtrapz(dt,Q);
Vishnuvardhan Naidu Tanga
Vishnuvardhan Naidu Tanga 2021 年 10 月 12 日
Thank you once again for sorting the thing out. Have a nice day.
Mathieu NOE
Mathieu NOE 2021 年 10 月 12 日
my pleasure (again) !

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by