matlab虚线缺一截,怎么设置legend使其一半虚线一半实线?

在Matlab中,当你遇到虚线部分缺失的问题时,可以使用`annotation`函数的`textarrow`属性来创建自定义图例。通过调整箭头的样式和位置,可以实现一半虚线一半实线的效果,如在示例代码中,利用'linestyle'参数分别设置为'-'和':',并添加文本字符串来表示75Hz的频率。
摘要由CSDN通过智能技术生成

Assume you use matlab

% Generate an example input data

dt = 0.0001;

t = -0.05 : dt : 0.05;

t0 = 0 : dt : 1/150;

f75Hz_p = [zeros(1, length(t(1) : dt : t0(1) - dt)), sin(2*pi*75*t0), zeros(1, length(t0(end) + dt : dt : t(end)))];

f75Hz_n = -[zeros(1, length(t(1) : dt : t0(1) - dt)), sin(2*pi*75*t0), zeros(1, length(t0(end) + dt : dt : t(end)))];

% Plot the data without any legend

figure(1);

plot(t, f75Hz_p, 'k-');

hold on;

plot(t, f75Hz_n, 'k:');

% By default, Matlab does not provide the legend property you want

% Therefore, you could use annotation textarrow property instead

% x and y are original positions for the textarrow, dx is used for

% incremental length of the textarrow

x = 0.15; y = 0.8; dx = 0.1;

% Drawing (headless) text arrows, so tha

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值