uva488 Triangle Wave

 
 Triangle Wave 

In this problem you are to generate a triangular wave form according to a specified pair of Amplitude and Frequency.

Input and Output

The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.

Each input set will contain two integers, each on a separate line. The first integer is the Amplitude; the second integer is the Frequency.

For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.

For the output of your program, you will be printing wave forms each separated by a blank line. The total number of wave forms equals the Frequency, and the horizontal ``height'' of each wave equals the Amplitude. The Amplitude will never be greater than nine.

The waveform itself should be filled with integers on each line which indicate the ``height'' of that line.

NOTE: There is a blank line after each separate waveform, excluding the last one.


输入输出格式易错

#include <stdio.h> int main() { int a, c, d, i, j, k; scanf("%d", &a); while (a--) { scanf("%d%d", &c, &d); for (i = 0; i < d; i++) { for (k = 1; k <= c; k++) { for (j = 0; j < k; j++) printf("%d", k); printf("\n"); } for (k = c-1; k >= 1; k--) { for (j = 0; j < k; j++) printf("%d", k); printf("\n"); } if (a != 0 || i != d - 1) printf("\n"); } } return 0; }


转载于:https://www.cnblogs.com/seebro/archive/2011/11/28/2476536.html

### 如何在 Simulink 中生成或处理 Triangle Wave #### 使用内置函数生成三角波 为了创建一个三角波,在 MATLAB 或者 Simulink 的环境中可以采用多种方法。一种简单的方式是在命令行输入 `sawtooth` 函数并调整其参数来获得期望的结果。对于特定需求,比如想要得到周期为 T 并且幅度范围限定于 [-1, 1] 的锯齿波,则可以通过设置合适的频率 f 和相移 phi 来实现;而如果目标是构建具有相同上升时间和下降时间特性的标准三角波而非锯齿波的话,那么就需要进一步修改该函数的行为模式[^1]。 ```matlab t = linspace(0, 2*pi, 1e3); tri_wave = sawtooth(t, 0.5); % duty cycle set to 0.5 for symmetric triangular waveform plot(t, tri_wave) xlabel('Time') ylabel('Amplitude') title('Triangular Wave Generated by Sawtooth Function') grid on; ``` #### 利用 Sine Wave Block 构建三角波发生器 另一种常见的做法就是通过组合多个基础组件来自定义设计所需的信号源。例如,基于正弦波振荡器原理,配合积分运算环节以及适当的限幅措施之后同样能够有效地合成出理想的三角波形。具体来说,先建立一个常规的正弦波模块(Sine Wave),将其输出连接至积分器之前加入绝对值计算节点以消除负半周部分的影响,最后再经由饱和元件设定上下界限即可完成整个电路搭建过程[^2]。 ```matlab % 定义Sine Wave Block参数 sine_wave_block = simulink.sources.SineWave; sine_wave_block.Amplitude = 1; % 归一化幅值 sine_wave_block.Frequency = 50; % 单位:Hz sine_wave_block.Phase = 0; % 单位:度 ``` #### Scope 显示与分析工具的应用 当涉及到实际项目开发过程中,往往还需要借助一些辅助手段来进行调试验证工作。此时便可以用到 Scope 组件所提供的强大可视化功能——不仅支持实时观测多路数据流变化趋势图样,而且允许用户自定义坐标轴刻度、颜色样式等外观属性以便更直观地区分不同类型的物理量关系。特别是在观察 SPWM 控制策略下的电力电子变换装置运行状态时尤为有用,因为这里会频繁涉及诸如正弦参考指令、三角调制载频及其对应的开关动作响应等一系列复杂动态特性表现形式[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值