matlab 矩阵连续大于,在Matlab中使用连续矩阵(Using consecutive matrices in Matlab)

在Matlab中使用连续矩阵(Using consecutive matrices in Matlab)

我正在创建一个在分析工作室中使用多个矩阵的函数。

矩阵的名称相同,名称中有日期参考(月份和年份:nov-1956是matrix5611 ,dec-1956是matrix5612 ,jan-1957是matrix5712 ,依此类推,直到1999年底。

对于每一个,每个月/每年的平均值之间应该进行比较(取决于您关注的研究领域)。

我正在尝试使用一些循环来改变输入矩阵的名称,而不是按日期手动编写,但是一个有用的函数。

任何想法或有用的功能?

I'm creating a function to use multiple matrices in an analysis studio.

The matrices are given with the same name with a date reference in the name (month to month and year to year: nov-1956 is matrix5611, dec-1956 is matrix5612, jan-1957 is matrix5712, and so on until the end of 1999.

For each one there should be a comparison between the mean value of each month/year (depending of what area of study are you focused on).

I'm trying to use some loops to vary the name of the input matrix instead of write manually date by date, but a function that helped would be useful.

Any idea or useful function?

原文:https://stackoverflow.com/questions/10487872

2020-02-23 22:02

满意答案

如果您的数据位于不同的矩阵中,则可以使用eval将平均值存储到某个矩阵,在本例中为MeanMatrix ,其中Y维度为年,X维度为月份:

编辑:它不是从5611运行的数字,但是yymm ...

编辑:似乎矩阵不是从1956年1月开始,而是从1956年11月开始。

% add here missing months matrix index strings.

MissingMatricesCellArray = {'5601', '5602', '5603', '5604', '5605', '5606', '5607', '5608', '5609', '5610'};

% MissingmatricesCellArray = {};

for Year = 56:99

for Month = 1:12

NumString = sprintf('%02d%02d', Year, Month);

% calculate and store means only for matrices that are not missing.

if ~(ismember (cellstr(NumString), MissingMatricesCellArray))

MeanMatrix(Year,Month) = mean(mean(eval ([ 'matrix', NumString ])));

end

end

end

然后,您可以按照您希望的方式比较月份和年份的平均值。

If you have your data in different matrices, you can use eval to store the means to some matrix, in this example MeanMatrix, in which Y dimension is year and X dimension is month:

Edit: It's not running number from 5611 but yymm...

Edit: It seems that matrices don't begin from January 1956 but from November 1956.

% add here missing months matrix index strings.

MissingMatricesCellArray = {'5601', '5602', '5603', '5604', '5605', '5606', '5607', '5608', '5609', '5610'};

% MissingmatricesCellArray = {};

for Year = 56:99

for Month = 1:12

NumString = sprintf('%02d%02d', Year, Month);

% calculate and store means only for matrices that are not missing.

if ~(ismember (cellstr(NumString), MissingMatricesCellArray))

MeanMatrix(Year,Month) = mean(mean(eval ([ 'matrix', NumString ])));

end

end

end

Then you can compare the means of months and years the way you wish.

2012-05-07

相关问答

如果你真的想,你可以这样做: X = reshape(diag(diag(A)),[],1)

我不确定你这样做会获得多少收益! If you really want to, you can do: X = reshape(diag(diag(A)),[],1)

I'm not sure you gain much by doing that though!

双阵列 只要结果是矩形的,您就可以通过将其他矩阵连接在一起来在MATLAB中创建矩阵。 因此,根据您的示例,可以通过执行以下操作来生成新的矩阵/向量,因为连接会产生矩形输出: u = rand(10,1);

v = rand(4,1);

newVector = [u;v];

但是,由于行数不同,您不能简单地将u和v连接到不同的列。 因此,需要填充某种类型以平衡行数: newMatrix = [ u , [v ; zeros(length(u)-length(v),1)]];

其中不存在...

使用单元阵列。 喜欢这个 c = cell(3,3) %Create cell array of size *3x3*

c =

[] [] []

[] [] []

[] [] []

c{1,1}; = rand(3,3); %Set cell {1,1} to be random matrix of size *3x3*

c{1,2} = ones(4,6) %Set cell {1,2} to be matrix of on...

假设您的阵列A是2-by-2-by-1000 ,这里有两个循环使事情有效: A = rand(2,2,1000);

K = 30;

%%

N = size(A,3);

APower = zeros(2,2,N,K);

APower(:,:,:,1) = A;

for i = 1:N

for k = 2:K

APower(:,:,i,k) = A(:,:,i)*APower(:,:,i,k-1);

%// Alternatively you could use...

在这种情况下,您可以在此类匹配的逻辑数组上使用max ,或者在此情况下沿着特定维度使用max ,并find 。 如果您正在寻找不匹配的唯一行ID,请执行此操作 - find(max(a~=b,[],2))

对于唯一的列ID,只需更改维度说明符 - find(max(a~=b,[],1))

样品运行 - >> a

a =

1 2 2 2 1

1 2 1 1 1

2 2 2 2 ...

解决问题的一线解决方案是: D = permute(cat(4, A, B), [1 4 2 3]);

但是,这需要一些解释。 这是一个让我们开始的例子: %# A 3-d pre-allocation example

A = rand(3, 3, 3);

B = rand(3, 3, 3);

D = NaN(3, 3, 3, 2);

D(:, :, :, 1) = A;

D(:, :, :, 2) = B;

如果您从预先分配所需的输出矩阵开始,然后手动将输入矩阵分配给输出矩阵,则问题在概念上...

如果您的数据位于不同的矩阵中,则可以使用eval将平均值存储到某个矩阵,在本例中为MeanMatrix ,其中Y维度为年,X维度为月份: 编辑:它不是从5611运行的数字,但是yymm ... 编辑:似乎矩阵不是从1956年1月开始,而是从1956年11月开始。 % add here missing months matrix index strings.

MissingMatricesCellArray = {'5601', '5602', '5603', '5604', '5605', '5...

你可以通过使用triu向矩阵及其转置移位来区分矩阵A的非对角元素:triu(A,1)和triu(A',1): sum(sum(triu(a,1)+triu(a',1)'))

如果你想对confusionMatrix {:}中的所有单元格这样做,你可以使用cellfun,然后排序: prediction_rate=cellfun(@(a) sum(sum(triu(a,1)+triu(a',1)')), confusionMatrix);

[r,idx]=sort(prediction_rate...

希望以下matlab代码可以帮到你! %by Mark 4/28/2015

clear all;

%%%%%%%%%%%%%%%%% take an example

m=4;

T=10;

y=zeros(1,T);

for i=1:(T)

y(i)=i;

end

%%%%%%%%%%%%%%%%%%%%%% calculate Ymin

count_i=0;

for i=m:1:(T-m)

count_i=count_i+1;

count_j=0;

...

基于bsxfun的矢量化解决方案,ab(使用) trace如何定义 - sum of diagonal elements - %// Get size of A

[m,n,r] = size(A)

%// Get indices of the diagonal elements for each 3D "slice" as columns of idx

idx = bsxfun(@plus,[1:m+1:m*n]',[0:r-1]*m*n) %//'

%// Thus, for your 3...

相关文章

中文名: MATLAB及应用 作者: 胡鹤飞 图书分类: 软件 资源格式: PDF

...

中文名: MATLAB智能算法30个案例分析 作者: 史峰 王辉 郁磊 胡斐

...

中文名: 模式识别与智能计算:MATLAB技术实现(第2版) 作者: 杨淑莹 图书分类:

...

中文名: 数字图像处理与机器视觉:Visual C++与Matlab实现 作者: 张铮 图

...

我想两次replace,分别把'和"替换为单引号和双引号,但在前台

...

今天给大家介绍一下经典的开源机器学习软件: 编程语言:搞实验个人认为当然matlab最灵活了(但是正版

...

转自:http://www.cnblogs.com/kshenf/archive/2012/06/14

...

机器学习之开源库大总结   研究数据挖掘和机器学习有一段时间了,对数据挖掘来说,商用软件有SAS、Cl

...

编 程语言:搞实验个人认为当然matlab最灵活了(但是正版很贵),但是更为前途的是python(nu

...

研究数据挖掘和机器学习有一段时间了,对数据挖掘来说,商用软件有SAS、Clementine、Ora

...

最新问答

如果启用了复制处理程序,请确保将其置于其中一个安全角色之后。 我见过人们做的另一件事是在不同的端口上运行admin。 最好在需要auth的页面上使用SSL,这样你就不会发送明确的密码,因此管理和复制将发生在8443上,而常规查询将在8080上发生。 如果您要签署自己的证书,请查看此有用的SO页面: 如何在特定连接上使用不同的证书? I didn't know that /admin was the context for SOLR admin because /admin does not re

第一:在您的样本中,您有: 但是你在询问 //td[@class=‘CarMiniProfile-TableHeader’] (注意TableHeader中的大写'T')。 xpath区分大小写。 第二:通过查询// td [@ class ='CarMiniProfile-TableHeader'] / td,你暗示你在外部td中有一个'td'元素,而它们是兄弟姐妹。 有很多方法可以在这里获得制作和模型

这是你的答案: http://jsfiddle.net/gPsdk/40/ .preloader-container { position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; background: #FFFFFF; z-index: 5; opacity: 1; -webkit-transition: all 500ms ease-out;

问题是,在启用Outlook库引用的情况下, olMailItem是一个保留常量,我认为当您将Dim olMailItem as Outlook.MailItem ,这不是问题,但是尝试设置变量会导致问题。 以下是完整的解释: 您已将olMailItem声明为对象变量。 在赋值语句的右侧,在将其值设置为对象的实例之前,您将引用此Object 。 这基本上是一个递归错误,因为你有对象试图自己分配自己。 还有另一个潜在的错误,如果之前已经分配了olMailItem ,这个语句会引发另一个错误(可能是

我建议使用wireshark http://www.wireshark.org/通过记录(“捕获”)设备可以看到的网络流量副本来“监听”网络上发生的对话。 当您开始捕获时,数据量似乎过大,但如果您能够发现任何看起来像您的SOAP消息的片段(应该很容易发现),那么您可以通过右键单击并选择来快速过滤到该对话'关注TCP Stream'。 然后,您可以在弹出窗口中查看您编写的SOAP服务与Silverlight客户端之间的整个对话。 如果一切正常,请关闭弹出窗口。 作为一个额外的好处,wireshar

Android默认情况下不提供TextView的合理结果。 您可以使用以下库并实现适当的aligntment。 https://github.com/navabi/JustifiedTextView Android Does not provide Justified aligntment of TextView By default. You can use following library and achieve proper aligntment. https://github.com/

你的代码适合我: class apples { public static void main(String args[]) { System.out.println("Hello World!"); } } 我将它下载到c:\ temp \ apples.java。 以下是我编译和运行的方式: C:\temp>javac -cp . apples.java C:\temp>dir apples Volume in drive C is HP_PAV

12个十六进制数字(带前导0x)表示48位。 那是256 TB的虚拟地址空间。 在AMD64上阅读wiki(我假设你在上面,对吗?)架构http://en.wikipedia.org/wiki/X86-64 12 hex digits (with leading 0x) mean 48 bits. That is 256 TB of virtual address space. Read wiki on AMD64 (I assume that you are on it, right?) ar

这将取决于你想要的。 对象有两种属性:类属性和实例属性。 类属性 类属性对于类的每个实例都是相同的对象。 class MyClass: class_attribute = [] 这里已经为类定义了MyClass.class_attribute ,您可以使用它。 如果您创建MyClass实例,则每个实例都可以访问相同的class_attribute 。 实例属性 instance属性仅在创建实例时可用,并且对于类的每个实例都是唯一的。 您只能在实例上使用它们。 在方法__init__中定

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值