文件的计算 [英] Calculations of files

查看:121
本文介绍了文件的计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 日价格1 price22000年2月2日10 152000年3月2日12 182000年4月2日14 19

有关每个值(价格1和价格2)我想计算不同=现在已经过去(2号线,一号线),每列。

为了使这是不是使用一个表,例如任何

我有什么

 文件= xlsread('example.xls');Y =长度(价);对于i = 1:Y;
  difprice1 =行(I + 1)行(I)
  difprice2 =行(I + 1)行(I)结束


解决方案

如果你的价格都存储在 M X N M 连续两天$ C>矩阵A和 N 不同的产品/价格,就可以得到每天的变化只需通过 A(2月底,:) - A(1:最终1:)

这需要计算所有第二天价格矩阵,减去所有元素今天的价格要素的矩阵,导致沿整个时间窗口中的所有价格的变化。

  A = xlsread('example.xls');
dA的= A(2:最终,:) - A(1:年底-1,:)

现在 dA的。(:, 2:结束)包含了所有你问的数字

Day              price1          price2

2/2/2000         10                15

3/2/2000         12                18

4/2/2000         14                19

For every value (price 1 and price 2) I want to calculate different = now-past (line2-line1) for every column.

To make this is it right to use a table, any example?

What I have

file = xlsread('example.xls');

y = length(price);

for i=1:y;
  difprice1 = line(i+1)-line(i)
  difprice2 = line(i+1)-line(i)

end

解决方案

If your prices are stored in an mxn matrix A with m consecutive days and n different products/prices, you can get the day to day change simply by A(2:end, :) - A(1:end-1, :).

This calculation takes the matrix of all "next day" prices and subtracts the matrix of all "today" prices element by element, resulting in all price changes along the entire time window.

A = xlsread('example.xls');
dA = A(2:end, :) - A(1:end-1, :)

Now dA(:, 2:end) contains all the numbers you were asking for.

这篇关于文件的计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆