Unable to concatenate the table variables
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am using readtable command to read data from .csv file as given below. One of the column contains varying quantity, and I would like to specify those values in commandwindow. How can I achieve this.
In the below code, I am getting error saying ''Unable to concatenate the table variables''. How to resolve this?
Thank you
R1 = 0.02; R2 = 0.03;
my_data_1 = readtable('my_data.csv')
my_data_2 = table2array(my_data_1(:,1:4));
4 Kommentare
Stephen23
am 13 Jun. 2022
"That is values assigned to R1 and R2 are of class 'complex'. "
MATLAB does not have a "complex" class type. Here are the fundamental MATLAB classes:
R1 could be char, or string, or categorical, or something similar.
Walter Roberson
am 13 Jun. 2022
The code is expecting that when the file is read, that any variable names in the text will be replaced with the value of the variable. However, MATLAB does not provide any file reading routines that will do that.
If you read the entire file as a character vector, and put '[' before and ']' after, and evalc() then possibly you would get what you are after.
... At least until someone puts
system('format C:\')
into an input file for the lulz.
Antworten (1)
Walter Roberson
am 12 Jun. 2022
Your Z column contains text but your other columns are numeric. It is not possible to create a single array that contains both text and numeric, other than converting to a cell array such as by using table2cell()
Note: when you assign values to variables, such as the way you assign to R1 and R2 here, and then you try to read from a file that contains text that matches variable names... then the values of the MATLAB variables will not be automatically substituted where the text occurs.
Also note that Excel has no way to represent complex numbers, so the 0.01+0.1j can only be read in as text.
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!