MATLAB中向量的级联 [英] Concatenation of Vectors in MATLAB

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

问题描述

我在MATLAB中有这10个向量,均值(alltmws {l}'),其中l为1到10.每个向量的大小为1X10001.现在,我想将所有这些值存储在一个向量中,一个接一个地存储,以便我可以计算和绘制总体均值.我该如何进行串联?任何帮助将不胜感激.

I have these 10 vectors in MATLAB, mean(alltmws{l}'), where l is from 1 to 10. The size of each of these vectors is 1X10001. Now I want to store all these values in one vector, one after the other, so that I can calculate and plot the overall mean. How can I do this concatenation? Any help will be greatly appreciated.

推荐答案

例如,如果您有

a{1} = rand(10,1);
a{2} = rand(10,1);
a{3} = rand(10,1);

你可以做

A = [a{:}];
A = A(:)

这个问题是模棱两可的,但是如果这是人们想要串联和绘制的方式,则可以执行以下操作:

The question is ambiguous, but if it is the means that one wants to concatenate and plot, you can do:

% Create example data
data = {};
for k = 1:10
  data{k} = rand(100,1);
end

% Compute and plot array of means
mu = []
for k = 1:length(data)
  mu(k) = mean(data{k});
end
plot(mu)

这篇关于MATLAB中向量的级联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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