显示数据点并将图表连接到一个文件中

时间:2014-02-04 07:41:09

标签: matlab plot scilab

您好我有几个Scilab问题,我希望有人能够回答。

首先,我需要在我的图表上显示某些数据点,这是不同循环的一部分。有一个简单的方法吗?也许像是

xstring(x,y,[value of x], [value of y])?

当我这样做时,它总是显示整个x和y矩阵,而不仅仅是那一点的值

其次,我有单独的文件,我想连接成1个pdf文件?我不知道该怎么做。

z = 1:3

scf(z)
plot(x,Y)

xs2pdf(z,filename)?

我试过这个,但我总是只将最后一张图片保存到pdf中。

先谢谢你

1 个答案:

答案 0 :(得分:0)

显示数据点

// Some function
x = 1:10;
y = x^2;

plot(x,y);

//Display fifth number
i = 5;

// Create a nice string label
stringToDisplay = sprintf("X: %d, Y: %d", x(i), y(i));

// Put it at the correct spot on the plot
xstring( x(i), y(i), stringToDisplay );

最好的方法是将它放在一个函数中:

function plotMyLabel(i)
    stringToDisplay = sprintf("X: %d, Y: %d", x(i), y(i));
    xstring( x(i), y(i), stringToDisplay );
endfunction

多个地块

您可以创建包含多个子图的图形并将其导出。请参阅scilab的subplot文档。

//plot first graph
subplot(1,2,1);

plot(x1,y1);

//plot second graph 
subplot(1,2,2);

plot(x2,y2);

// Format the figure at will
fig = gcf();

fig.figure_size=[1200, 800];
fig.children.margins = [0.05, 0.05, 0.05, 0.05];

//export to file
xs2pdf(fig, 'my_out_file');