首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >每次在MATLAB中运行代码时,如何更新excel表格中下一列中的计算数据?

每次在MATLAB中运行代码时,如何更新excel表格中下一列中的计算数据?
EN

Stack Overflow用户
提问于 2018-07-21 17:29:17
回答 1查看 67关注 0票数 1
代码语言:javascript
复制
function []= process(f1, f2, f3, f4, height, th)

%%omitted the the large code from in between in order to just propose the problem%% 

ValuesInInches(12)=t1*t;
ValuesInInches(8)=realneck(f1,f2,height,th);
ValuesInInches(14)=t3*t; 
ValuesInInches(7)=t4*t;
ValuesInInches(11)= ValuesInInches(7);
ValuesInInches(5)=t5*t;
ValuesInInches(4)=t6*t;
ValuesInInches(6)=t7*t;
ValuesInInches(10)=t8*t;
ValuesInInches(9)=t9*t;
ValuesInInches(3)=t9*t1;
ValuesInInches(1)=t*t10;
ValuesInInches(2)=t11*t;
ValuesInInches(13)= measureknee(a5,t);
ValuesInInches=ValuesInInches';

file='measure.csv';

measurements{1,1}='Shirt Length';
measurements{2,1}='Full Shoulders';
measurements{3,1}='Sleeves';
measurements{4,1}='Muscle';
measurements{5,1}='Chest';
measurements{6,1}='Stomach';
measurements{7,1}='Hip';
measurements{8,1}='Neck';
measurements{9,1}='Trouser length';
measurements{10,1}='Trouser waist';
measurements{11,1}='Trouser hip';
measurements{12,1}='Thigh';
measurements{13,1}='Knee';
measurements{14,1}='Inseam';

T= table(measurements,ValuesInInches);
writetable(T,file);

end

我必须在每次更改代码时更新文件measure.csv,以便创建一组数据值。我可以将数据写入文件,但现在我需要的是,当我的代码第二次运行时,它将计算出的数据写入下一列,同时保护旧数据的安全。我的代码要么覆盖同一列中的数据,要么每次都必须手动输入特定的行列交叉点位置。

我的代码每次运行都会计算14个值。请告诉我一种方法,这样我就可以在我的父函数中使用它,使整个过程更有效率。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-23 02:35:24

首先,如果你正在编写一个Excel表格,我建议你使用函数xlswrite(filename,Data,sheet,pos),它允许你在表格中的特定位置特别设置一个值,向量或矩阵。

第二:如果你可以使用一个跟在你写的行数后面的计数器,你可以这样做:

代码语言:javascript
复制
function []= process(f1, f2, f3, f4, height, th, counter)
% Your code...
% suppose you want to write ValuesInInches into the next row

strCounter = ('A':'Z'); % = 'ABC...Z'
strPos = [strCounter(counter) '1']; % = 'B1' for instance
xlswrite(file,ValuesInInches,strPos);

end

我希望这能帮到你。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51454687

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档