Getting an error message when I use 'triangle()' function.
이전 댓글 표시
I wrote a code to create a tiangle wave form for testing my functions as below:
close all; clearvars; clc;
t = 0:0.01:10*pi;
f = 5;
A = 10;
y = A * triangle(2*pi*t);
figure, plot(y);
But I am getting a Command Window error message as below:
Unrecognized function or variable 'triangle'.
Error in ucgenDalga (line 5)
y = A * triangle(2*pi*t);
I tested the code first in MATLAB 2022b and then in MATLAB Online, having the same error message. When I wrote "help triangle" in Command Window, MATLAB responds an answer. But when I use triangle function in my code, I am receiving the above error. I could not have got an answer from Internet search. Any idea is appreciated.
댓글 수: 3
help triangle
VBBV
2024년 3월 24일
The documentation states this function is for use in Stateflow estimation
Baris Dogan
2024년 3월 24일
채택된 답변
추가 답변 (1개)
close all; clearvars; clc;
t = 0:0.01:10*pi;
f = 5;
A = 10;
y = A * sawtooth(2*pi*t);
figure, plot(t,y); xlim([0 2*pi])
댓글 수: 3
VBBV
2024년 3월 24일
use sawtooth function which can generate triangular waveforms
Baris Dogan
2024년 3월 24일
You can modify your code using sawtooth in https://www.mathworks.com/help/signal/ref/sawtooth.html to suit what you want
close all; clearvars; clc;
t = 0:0.01:10*pi;
f = 5;
A = 10;
y = A * sawtooth(2*pi*t,1/2); % triangle wave with two equal sides
figure, plot(t,y); xlim([0 pi])
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



