problem with table / array/cell

조회 수: 15 (최근 30일)
venkat ta
venkat ta 2020년 6월 3일
댓글: venkat ta 2020년 6월 3일
Hi ,
The function is converting table to cell instead of table to array matrix.
I need a simple array vector for each column to plot and to do further calculation
clear all;
close all;
clc;
TXT_FileName='Fundamental + Harmonic distortion components.txt';
filedata = readtable(TXT_FileName,'delimiter','\t','readvariablenames',true);
A = table2array(filedata);
array = table2array(filedata(3:end,:));
% row=2;
% A(row,:)=[];
% row=1;
% A(row,:)=[];
Freq = array(:,1);
All_Fun_SPL = array(:,2);
% plot(Freq(:,1),All_Fun_SPL(:,1));
  댓글 수: 2
Mohammad Sami
Mohammad Sami 2020년 6월 3일
I think the readtable is not detecting your header rows, you may want to explicitly state how many header rows there are. This causes it import data as cell string rather then as numeric values.
venkat ta
venkat ta 2020년 6월 3일
Totally, 12 col and 6 pairs x y graphs (odd are x and even are y)

댓글을 달려면 로그인하십시오.

답변 (1개)

Stephan
Stephan 2020년 6월 3일
편집: Stephan 2020년 6월 3일
Your table content is a cell array - Read the Tips section from the documentation. It tells you why and how to deal with it.
cell2mat(table2cell(T))
  댓글 수: 1
venkat ta
venkat ta 2020년 6월 3일
Hi,
The cell2mat makes error like below
Error using cat
Dimensions of arrays being concatenated are not consistent.
Error in cell2mat (line 83)
m{n} = cat(1,c{:,n});
clear all;
close all;
clc;
TXT_FileName='Fundamental + Harmonic distortion components.txt';
filedata = readtable(TXT_FileName,'delimiter','\t','readvariablenames',true);
M=cell2mat(table2cell(filedata));

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by