select a specific element of each matrix in a string

1 次查看(过去 30 天)
Hi,
this is my code
K=rand(448);
for i=1:448
g{i}=[0:1:447]';
end
for i=1:448
U{i}=inv(K)*g{i};
end
so U contain 448 element containing 448*1 in each matrix. Now I want to use element(1,1) of each matrix. what should I do?
  1 个评论
Codeshadow
Codeshadow 2020-6-1
One way to go about it would be as below:
tmp = [U{1,:}]; % Places all the data from the cell array into a 448*448 matrix.
Solution = tmp(1,:); % Gets the first element of each U.
clear tmp
Hope that helps!

请先登录,再进行评论。

采纳的回答

the cyclist
the cyclist 2020-6-1
编辑:the cyclist 2020-6-1
firstElementOfEachCellOfU = cellfun(@(x)x(1,1),U);
  2 个评论
talayeh tavangar
talayeh tavangar 2020-6-1
thank you very much. Now, I have 2 matrix of 1*448 I want to plot them as U for X axis and K as Y axis how can I do that?
the cyclist
the cyclist 2020-6-1
Since this particular question has been answered, I suggest you ask this in a new question (and upvote and/or accept useful answers that you have been receiving on prior questions).

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by