Finding the length of square function

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 个评论

Be far more clear about what you are trying to do. You want to find the length of a function? Are you asking to compute the arc length? Next, of what function? Be explicit, else we will spend time showing you how to solve the wrong problem.
I am sorry. I'm using this code for square function.
t=linspace(0,20,100);
X=3*square(2*pi*t/10)
plot(X,t)
I want to check how long the plot for that function is. I'm checking different patterns and seeing their distance.
Did you try to google how to calculate the arc length of a function in Matlab?
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

请先登录,再进行评论。

 采纳的回答

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 个)

类别

帮助中心File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by