Use for loops to give the values of the following function: f(x) = 3x2 + 5x – 7 x < 0 3x + 4 x >= 0
for -10 <= x <= 10 in steps of 1

답변 (1개)

David Hill
David Hill 2020년 3월 29일

0 개 추천

x=-10:10;
for k=1:length(x)
if x(k)<0
f(k)=3*x^2+5*x-7;
else
f(k)=3*x+4;
end
end

카테고리

도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2020년 3월 29일

답변:

2020년 3월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by