Continuous Graph in a loop

3 vues (au cours des 30 derniers jours)
Nick Sharma
Nick Sharma le 14 Juin 2019
Commenté : Nick Sharma le 14 Juin 2019
Hi
My code is as below
i=0:1:10;
x=1;
if i<=3
B=3+x;
else
B=x;
plot(i,B,'*')
hold on
end
================
First of all my graph is not matching my expected result.
Secondly in my expected graph I want continuos line .
Please help .

Réponse acceptée

Walter Roberson
Walter Roberson le 14 Juin 2019
i = 0:1:10;
x = 1;
B = x * ones(size(i));
mask = i <= 3;
B(mask) = i(mask) + 2;
plot(i, B,'-*')
  1 commentaire
Nick Sharma
Nick Sharma le 14 Juin 2019
Walter .....You are a Gem of a person ......thans bro.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by