troubles with trapz function

12 ビュー (過去 30 日間)
Christos Papagrigoriou
Christos Papagrigoriou 2020 年 3 月 1 日
コメント済み: Star Strider 2020 年 3 月 1 日
hello
I Have a matrix that i have plotted on Matlab (it is the xls file attached). I need to find the area of the graph based on that data. I am using trapz function but it turns back with an error. Any help with that would be more than appreciated.
Kind regards
  1 件のコメント
Christos Papagrigoriou
Christos Papagrigoriou 2020 年 3 月 1 日
Error using trapz (line 64)
Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not
supported. Use a row subscript and a variable subscript.
Error in stressplatform1 (line 42)
impulsemomentsquat1= trapz(x,y);
this is the exact eeror displayed. Would it be too much of a bother if I d ask to see what you did?
Cheers

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

採用された回答

Star Strider
Star Strider 2020 年 3 月 1 日
We likely took the same approach. There are several ways to access the data in table objects, as described in the documentation.
Try this:
T1 = readtable('stressplatformexp.xlsx');
x = T1{:,1};
y = T1{:,2};
A = trapz(x, y);
figure
patch([x; flipud(x)], [y; zeros(size(y))], 'g', 'FaceAlpha',0.5)
grid
text(6, 140, sprintf('Area = %.3f',A), 'HorizontalAlignment','center')
  2 件のコメント
Christos Papagrigoriou
Christos Papagrigoriou 2020 年 3 月 1 日
u saved my degree luv ya
Star Strider
Star Strider 2020 年 3 月 1 日
Thank you!
If my Answer helped you solve your problem, please Accept it!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by