我正在尝试使用scilab在同一张图上显示3条测量和理论曲线,以进行比较。问题在于,尽管两条曲线的数据集大小相同,但理论曲线应该由数据集大得多的函数创建,尽管它们的范围都相同。
D1和D2具有13个要显示的值,D0中x轴的13个值将显示(刻度应在0到500之间)。 理论函数应该沿着从0到500的linspace而不是13的值显示,而不仅仅是13。这样所有的曲线在x轴上都与从o到500的tiks对齐。
我尝试使用下面显示的代码,但它只会显示D1和D2的曲线。
我的代码:
clc;
clear;
xdel(winsid());
D0 = [0, 40, 80, 120, 160, 200, 240, 280, 320, 360, 400, 440, 480];
//x axis for D1 and D2
D1 =[4.96, 5, 4.96, 4.96, 4.96, 4.96, 4.96, 4.96, 4.95, 4.96, 4.96, 4.96, 4.96]; //first curve
D2 =[0, 1.61, 2.73, 3.58, 4.05, 4.24, 4.56, 4.72, 4.93, 4.88, 4.90, 4.90, 4.95]; //second curve
foo1 = (-5)*(1-%e^((-1)/(0.1)*(linspace(0, 1, 500)))); //the problematic function that will not show on the plot when the other curves are displayed
scf();
aa = gca();
aa.font_size=3;
aa.thickness=2;
plot(D0, D1, "r-", "fontsize",5);
plot(D0, D2, "g-", "fontsize",5);
plot(linspace(0, 1, 500), foo1);
我希望3条曲线在x轴为0到500的同一图形上。
答案 0 :(得分:1)
您在linspace函数中犯了一个错误,应该使用类似的内容
linspace(0, 500, 1000);
第一个点,最后一个点,值的数量。