Matlab 中分段函数图中的间隙

发布于 2024-10-10 00:03:54 字数 434 浏览 2 评论 0原文

我想绘制一个分段函数,但我不希望在接合处出现任何间隙

,例如:

t=[1:8784];

b=(26.045792 + 13.075558*sin(0.0008531214*t - 2.7773943)).*((heaviside(t-2184))-(heaviside(t-7440)));

plot(b,'r','LineWidth', 1.5);grid on

不应该出现任何间隙 三个间隔之间的情节,但它们确实如此。

我希望图表是连续的,没有间隙。

关于如何实现这一目标的任何建议。

提前致谢。

编辑
其实我的目的是找到下图中黄色的载体函数。我将整个区间分为3个区间:1-常数 2-正弦 3-常数,然后我想从这三个函数中找到整体函数

I want to plot a piecewise function, but I don't want any gaps to appear

at the junctures, for example:

t=[1:8784];

b=(26.045792 + 13.075558*sin(0.0008531214*t - 2.7773943)).*((heaviside(t-2184))-(heaviside(t-7440)));

plot(b,'r','LineWidth', 1.5);grid on

there should not be any gaps appearing in
the plot between the three intervals , but they do.

I want the graph to be continueous without gaps.

Any suggestions on how to achieve that.

Thanks in advance.

EDIT
Actually, my aim is to find the carrier function colored by yellow in the figure below. I divide the whole interval into 3 intervals: 1-constant 2-sinusoidal 3- constant, then I want to find the overall function from the these three functions

alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请别遗忘我 2024-10-17 00:03:54

当然也有“差距”。对于所有t<2184和对于所有t>7440,复合函数同样为零。这些关系只能在该区间内为非零。而且您没有选择端点为零的函数,那么您怎么能期望不存在“间隙”呢?

您的函数在区间端点处采用什么值?

>> t = [2184 7440];
>> (26.045792 + 13.075558*sin(0.0008531214*t - 2.7773943))
ans =
       15.689       20.616

那么看看这个帽子功能部分。我会偷懒,用ezplot。

>> ezplot(@(t) ((heaviside(t-2184))-(heaviside(t-7440))),[0,8784])

alt text

现在,将其组合起来,将其乘以三角函数,当然,在该域之外,结果为零。

>> ezplot(@(t) (26.045792 + 13.075558*sin(0.0008531214*t - 2.7773943)).*((heaviside(t-2184))-(heaviside(t-7440))),[0,8784])

alt text

但是,如果您的目标是帽子函数中两个选定点的某种连续函数,您需要选择三角函数部分,使其在相同的两点处为零。数学不拼写为mathemagics。希望你得到一个连续函数不会实现。

那么,您真正的问题是如何选择内部片段(片段)以使最终结果是连续的?如果是这样,那么我们需要知道为什么你选择了其中的任意常数。当然,这些数字 {26.045792, 13.075558, 0.0008531214, 2.7773943} 对您来说一定有一定的意义。如果它们很重要,那么我们如何才能使结果成为连续函数呢?

也许,我只是在这里猜测,您想要从中得到一些其他结果,使得该函数在这些界限之外不完全相同为零。也许您希望将其推断为这些点之外的常数函数。但要帮助你,你必须帮助我们。

Of course there are "gaps". The composite function is identically zero for all t<2184, and for all t>7440. The relationships can only be non-zero inside of that interval. And you have not chosen a function that is zero at the endpoints, so how can you expect there not to be "gaps"?

What values does your function take on at the endpoints of the interval?

>> t = [2184 7440];
>> (26.045792 + 13.075558*sin(0.0008531214*t - 2.7773943))
ans =
       15.689       20.616

So look at the hat function part of this. I'll be lazy and use ezplot.

>> ezplot(@(t) ((heaviside(t-2184))-(heaviside(t-7440))),[0,8784])

alt text

Now, combine this, multiplying it by a trig piece, and of course the result is identically zero outside of that domain.

>> ezplot(@(t) (26.045792 + 13.075558*sin(0.0008531214*t - 2.7773943)).*((heaviside(t-2184))-(heaviside(t-7440))),[0,8784])

alt text

But if your goal is some sort of continuous function across the two chosen points in the hat function, you need to chose the trig part such that it is zero at those same two points. Mathematics is not spelled mathemagics. Wishing that you get a continuous function will not make it so.

So is your real question how to chose that internal piece (segment) as one such that the final result is continuous? If so, then we need to know why you have chosen the arbitrary constants in there. Surely these numbers, {26.045792, 13.075558, 0.0008531214, 2.7773943} all must have some significance to you. And if they are important, then how can we possibly make the result a continuous function?

Perhaps, and I'm just guessing here, you want some other result out of this, such that the function is not identically zero outside of those bounds. Perhaps you wish to extrapolate as a constant function outside of those points. But to help you, you must help us.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文