
matlab变量设置问题 100分
UpdatetheglobalvariableDatathatyou'reusingtostorethehorizontalforce,thecalculatedleng...
Update the global variable Data that you're using to store the horizontal force , the calculated length and the plot handle for each of the iterations. Basically, we want to append three values (HF , calc_length and handle ) as the next row of Data during each iteration (i.e. during each call to this function). Each of the three values should be added as a new row to Data. Take the Data that existed from the previous iteration, and adds the HF , calc_length and handle from this iteration to it. This will create a timeline of horizontal forces and lengths. We'll use this later to plot how we approached the optimal answer.
The variable Data should therefore be a matrix with i rows and 3 columns; where i is the number of iterations we perform. The first element in each row (the entire first column) will contain the horizontal forces that you calculate at each iteration, and the second element in each row (the entire second column) will contain the springs lengths that you calculate at each iteration and the third element in each row( the entire third column) will contain the plot handle at each iteration.
After i iterations, Data should have this structure:
Data = [ HF1 calc_length1 handle1;
HF2 calc_length2 handle2;
HF3 calc_length3 handle3;
... ...
HFi calc_lengthi handlei]
这个问题中,Data要怎么写? 展开
The variable Data should therefore be a matrix with i rows and 3 columns; where i is the number of iterations we perform. The first element in each row (the entire first column) will contain the horizontal forces that you calculate at each iteration, and the second element in each row (the entire second column) will contain the springs lengths that you calculate at each iteration and the third element in each row( the entire third column) will contain the plot handle at each iteration.
After i iterations, Data should have this structure:
Data = [ HF1 calc_length1 handle1;
HF2 calc_length2 handle2;
HF3 calc_length3 handle3;
... ...
HFi calc_lengthi handlei]
这个问题中,Data要怎么写? 展开
2个回答
2014-02-23
展开全部
这段描述真够啰嗦的,反反复复说了很多,基本意思就是:写一个函数,每次调用这个函数时,都对一个全局变量Data进行更新,在最后面追加一行(三个数据:HF, calc_length, handle)。但你的问题不完整,例如,HF和calc_length怎样计算,handle怎样绘图?
如果仅就这个函数而言,大致的内容如下:
function update
global Data
% 此处加入计算HF、calc_length以及绘图的代码
Data(end+1,:) = [HF, calc_length, handle];
更多追问追答
追答
没有确切的数据,无法进行测试,所以不敢保证写出来是对的,方法大致如下。
如果HF和h、d都已知,可以用向量化的写法:
Fi = HF * sqrt(1+(diff(h)./d(2:end)).^2);
如果h和d的值需要在迭代的过程中计算,那么就使用循环的做法:
for i = 1:N+1
% 这个位置计算h和d
Fi(i) = HF * sqrt(1+((h(i+1)-h(i))/d(i+1))^2);
end
需要注意的是,MATLAB数组下标是从1开始的。

2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
展开全部
他的意思是,在每次迭代中,都把每次计算出来的水平力(horizontal force),与弹簧的长度,以及画图的句柄保存在data中,假如有N次迭代,那么data应该是N行3列。我看英文介绍就是这些意思,具体的,力与长度,怎么计算得看你的公式,还有句柄handle=plot(x,y)
Data = [ HF1 calc_length1 handle1;
HF2 calc_length2 handle2;
HF3 calc_length3 handle3;
... ...
HFi calc_lengthi handlei]
Data = [ HF1 calc_length1 handle1;
HF2 calc_length2 handle2;
HF3 calc_length3 handle3;
... ...
HFi calc_lengthi handlei]
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询