for idx = 1 hold on plot(idx,d​ensity(idx​),"*") hold off pause(0.2) end showing incorrect

61 visualizzazioni (ultimi 30 giorni)

Name your loop counter idx. For the first execution of the loop, idx should have a value of 1, and it should increase by 1 each consecutive iteration.

Risposte (5)

KSSV
KSSV il 6 Lug 2022
density = density(:) ;
idx = (1:length(density))' ;
figure
plot(idx,density)
comet(idx,density)

Neyely Magnoly
Neyely Magnoly il 18 Set 2022
Envuelva el código de la segunda sección del script en tiempo real (líneas 4-7) en un bucle para que el código se ejecute 7 veces.
Asigne al contador de bucle el nombre idx. Para la primera ejecución del bucle, idx debe tener un valor de 1, que debe aumentar en 1 con cada iteración consecutiva.

Walter Roberson
Walter Roberson il 18 Set 2022
for idx = 1:MaximumNumberOfIterationsGoesHere

ALI
ALI il 29 Mar 2024 alle 21:32
TASK
Wrap the code on lines 4–5 of the live script in a for loop so that the code executes 10 times.
Name your loop counter idx. For the first execution of the loop, idx should have a value of 1, and it should increase by 1 in each consecutive iteration.

Sunil
Sunil il 17 Apr 2024 alle 10:11
Wrap the code on lines 4–5 of the live script in a for loop so that the code executes 10 times.
Name your loop counter idx. For the first execution of the loop, idx should have a value of 1, and it should increase by 1 in each consecutive iteration.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by