To read a cell array

To read a particular column of a cell array using the position of header name.

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日

0 投票

Example
A=num2cell(magic(5))
Col=3
A(:,col)

17 件のコメント

sarfudeen
sarfudeen 2013 年 3 月 29 日
how to access the column data in uitable.
sarfudeen
sarfudeen 2013 年 3 月 29 日
how to access the particular element in a cell array using strcmp
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日
編集済み: Azzi Abdelmalek 2013 年 3 月 29 日
A=num2cell(magic(5))
t = uitable( 'Data',A)
% to read column 2
out=get(t,'Data')
col2=out(:,2)
sarfudeen
sarfudeen 2013 年 3 月 29 日
how to access multiple columns using loops
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日
you do not need loops to access multiple columns
A=num2cell(magic(5))
col=[1 2 4]
A(:,col)
sarfudeen
sarfudeen 2013 年 3 月 29 日
ok thanks how to multiply the two cell array column
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日
which cell array column?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日
p=cellfun(@times,col1,col2)
sarfudeen
sarfudeen 2013 年 3 月 29 日
have 719 X 2 cell, would like to divide or multiply the 2 columns within the cells
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日
編集済み: Azzi Abdelmalek 2013 年 3 月 29 日
A=num2cell(rand(719,2)) % Example
p=cellfun(@times,A(:,1),A(:,2))
Or use @rdivide
sarfudeen
sarfudeen 2013 年 3 月 29 日
error occurred as 'matrix dimensions must agree'
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日
There is no error with my example, post your code
sarfudeen
sarfudeen 2013 年 3 月 29 日
my code:
data = cellfun(@rdivide,meas(:,32),meas(:,33),'UniformOutput',false);
I have 60 numbers of columns in my "meas" file.
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日
meas is a cell array or a file?
sarfudeen
sarfudeen 2013 年 3 月 29 日
meas is a cell array of type cell
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日
編集済み: Azzi Abdelmalek 2013 年 3 月 29 日
In windows command type
whos meas
what did you get?
sarfudeen
sarfudeen 2013 年 3 月 29 日
Name = meas Size = 720x60 Bytes = 3112252 Class = cell Attributes =

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

質問済み:

2013 年 3 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by