Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how can i write such code using vectorisation

조회 수: 5 (최근 30일)
omar ayman abdellateef
omar ayman abdellateef 2020년 4월 29일
마감: MATLAB Answer Bot 2021년 8월 20일
how can i do this i'm asked to code this but i got no idea how to do it:
"Use vectorisation to achieve the following (no loops or if statements allowed):
create an array x which starts at 0 and ends and 8*pi in increments of pi/100.
create another array y which is equal to sin(x).
then use vectorisation to change all values below the axis to be set to 0"

답변 (1개)

Raunak Gupta
Raunak Gupta 2020년 5월 3일
Hi,
You may find below code useful to solve above question.
x = 0:pi/100:8*pi;
y = sin(x);
y(y<0) = 0;

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by