x=0:pi/100:2*pi; y=sin(x); if x>3 plot(x,y,"b*") else x<=3; plot(x,y,"g*") end I Want PLot X>3 using Defferent Color

8 Ansichten (letzte 30 Tage)
clc;clear;close all
x=0:pi/100:2*pi;
y=sin(x);
if x>3
plot(x,y,"b*")
else x<=3;
plot(x,y,"g*")
end

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 3 Dez. 2021
x=0:pi/100:2*pi;
y=sin(x);
mask = x > 3;
plot(x(mask), y(mask), "b*")
hold on
plot(x(~mask), y(~mask), "g*")
hold off

Weitere Antworten (0)

Kategorien

Mehr zu Messages finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by