Creating a piecewise function using for and if

For an assignment, I need to create a piecewise graph using only for and if statements, but I have two equations, 15 + 2*(x-1), x>=2, and 15 if x is between 0 and 2 for a data set of 0:0.1:5 I am not sure how I would construct this.

 채택된 답변

Chunru
Chunru 2022년 9월 20일

0 개 추천

% Here are some hints for your try
% data set of 0:0.1:5
x = 0:0.1:5;
% for loops over x
for i=1:length(x)
% if statements
if x(i) satisfies certain conditions
do whatso ever
else
do something else
end
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 9월 19일

답변:

2022년 9월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by