Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

how can i write such code using vectorisation

1 visualizzazione (ultimi 30 giorni)
omar ayman abdellateef
omar ayman abdellateef il 29 Apr 2020
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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"

Risposte (1)

Raunak Gupta
Raunak Gupta il 3 Mag 2020
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