【发布时间】:2020-05-07 19:40:48
【问题描述】:
我正在使用 BNT-toolbox,这是一个用 matlab 编写的大型库,用于在贝叶斯网络中进行推理。
我不得不将此工具箱添加到 MATLAB 的路径中。但是在这样做之后,我就不能再使用默认的legend 函数了。
我认为这个库可能有他自己的legend 函数,覆盖了默认的。如何手动告诉 MATLAB 我想要原始工具箱而不是新工具箱中的工具箱?
在 Matlab 2018b 和 2020a 中尝试过
编辑:重现它:
当我运行测试脚本时,它会显示线条和图例。
https://github.com/bayesnet/bnt,这就是我说的工具箱。我下载了它,解压缩然后将它添加到我的路径 Home -> Set path -> add folder with subfolder
当我现在运行脚本时,它显示的是线条而不是图例。
注意:当我尝试另一种绘图方式时(参见测试脚本 2),图例再次显示。所以这是一个有效的“解决方法”
Testscript1:(位置:C:\Users\TomDe\Downloads\FullBNT-1.0.7\bnt\own\testscript1.m)
x = linspace(0,pi);
y1 = cos(x);
plot(x,y1)
hold on
y2 = cos(2*x);
plot(x,y2)
legend('cos(x)','cos(2x)')
测试脚本2
% Some other code
tiledlayout(2,1)
nexttile
plot(inputPath)
hold on
plot(sensorPath)
plot(inputInference)
hold off
title('The Input sequence and sensor readings ')
legend('Path', 'sensor', 'Inference')
【问题讨论】: