Finding the length of square function

2 ビュー (過去 30 日間)
Dimo Iordanov
Dimo Iordanov 2020 年 12 月 7 日
回答済み: Rik 2020 年 12 月 8 日
Hello, I'm using the square function. I want to find the length of it based on my limits. How can I do that since the square root is discontinues. Regards, Dimo
  4 件のコメント
Rik
Rik 2020 年 12 月 8 日
Did you try to google how to calculate the arc length of a function in Matlab?
Dimo Iordanov
Dimo Iordanov 2020 年 12 月 8 日
Yes, I did, and found the length of a sine function that I did before. I can use the same principle for finding a square function, but I think that it is going to get too messy. This is why I was wondering if anyone had any easier way of doing it. By messy I mean that the square functions are actually two functions that are activating by different values, and I believe I can solve it with a loop, by calculating each section of the wave, but I was wondering if there isn't a simpler way.
Regards,
Dimo

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

採用された回答

Rik
Rik 2020 年 12 月 8 日
In general you can approximate the arc length by measuring the distances between the points and adding them.
t=linspace(0,20,100);
X=3*square(2*pi*t/10);
sum(hypot(diff(t),diff(X)))
Just a side note: I found this answer by John D'Errico as the 5th result when I googled 'arc length Matlab' detailing several methods to calculate the arc length. I suggest you take a look there as well.

その他の回答 (1 件)

Rafael Hernandez-Walls
Rafael Hernandez-Walls 2020 年 12 月 8 日
t2=t(find(diff(X)>0));
t1=t(find(diff(X)<0));
long_time=t2(2)-t1(2)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by