如何以特定间隔绘制具有形状的线?

How to draw line with a shape at a specific interval?

我的密码是

f = myfunc1(...); % (f=1x4 cell) % (f{i} : 1x1000000 matrix)
g = myfunc1(...); % (g=1x4 cell) % (g{i} : 1x1000000 matrix)
color = {'red', 'blue', 'green, 'black};
leg = {'~~~', '~~~', '~~~', '~~~'};
for i=1:4
    figure(1);
    plot(f{i}, color{i});
    hold on;grid on;

    figure(2);
    plot(g{i}, color{i});
    hold on;grid on;
end
for i=1:2
    fig = figure(i);
    legend(leg);
end

这给出了两个图形,每个图形都有四条不同颜色的线。 但是,它们在显示器中是可区分的,但在黑白打印纸上却无法区分。 因此,我尝试添加一些形状,例如圆形、星形、点等。 我想在每条线上放置一种形状。 (不是每个点,而是每 100 点。)

实际上,我可以在结果上额外绘制形状,但图例没有改变。有没有画形状的功能?

plot命令创建的line对象有一个MarkerIndices属性可以用来获取你想要的:

x = linspace(0,10,1000);
y = exp(x/10).*sin(4*x);
plot(x,y,'-*','MarkerIndices',1:10:length(y))

示例取自 https://www.mathworks.com/help/matlab/creating_plots/create-line-plot-with-markers.html

的 MATLAB 文档

请注意,这也与图例互动良好。