我看到一些过于复杂的例子,说明如何在Matlab中完成,但Scilab怎么样?我成功地将单个列向量写入output.csv,但是如何将多个列向量写入相同的output.csv。下面打印单个列向量的代码,它显示了我想要输出到output.csv的其他列向量(速率,累积)。怎么做?
感谢。
//import csv data
data_import = evstr(csvRead('input.csv', ','));
//extraction of columns and definition of variables
time=data_import(:,1)
rate=data_import(:,2)
cumulative=data_import(:,3)
//multiplication of time in hours by 2
timetimestwo=time*2
//export csv and print new variable
csvWrite(timetimestwo,'output.csv',' ');

*注意:我添加了一种方法将三列打印到一列,但我仍然想打印成3列矩阵,我不确定为什么这三列不是分手了。我这样做了:
M = [timetimestwo; rate; cumulative]
for i = 1:3
csvWrite(M,'output.csv',',','.')
end

答案 0 :(得分:0)
分号使它成为一个大的列矩阵,你应该使用逗号。在下面的插图中,您可以看到概念,......的种类。
| | |[timetimestwo(1)],[rate(1)],[cumulative(1)]|
| | |[timetimestwo(2)],[rate(2)],[cumulative(2)]|
|[timetimestwo],[rate],[cumulative] | = |[timetimestwo(3)],[rate(3)],[cumulative(3)]|
| | |[timetimestwo(4)],[rate(4)],[cumulative(4)]|
| | |[timetimestwo(5)],[rate(5)],[cumulative(5)]|
问题的一个工作示例是:
//import csv data
data_import = evstr(csvRead('input.csv', ','));
//extraction of columns and definition of variables
time=data_import(:,1)
rate=data_import(:,2)
cumulative=data_import(:,3)
//multiplication of time in hours by 2
timetimestwo=time*2
M=[timetimestwo,rate,cumulative]
//export csv and print new variable
csvWrite(M,'output.csv',' ');