Brace indexing error when using MATLAB cell2mat() function
I can't understand why I'm suddenly getting an error even though I've used cell2mat in the same way for prior codes. The error reads
Brace indexing is not supported for variables of this type.
Error in cell2mat
cellclass = class(c{1});
And the corresponding code is
clear all;
close all;
clc;
parta = xlsread('C:\Users\Zahin\Desktop\Fall 2018\MEC 516\Lab 9\Data.xlsx',1,'A3:R15');
partb = xlsread('C:\Users\Zahin\Desktop\Fall 2018\MEC 516\Lab 9\Data.xlsx',2,'A3:K11');
a_rg = cell2mat(parta(:,1));
My goal is to turn these cells into column vectors so that I can use the plot function. When I do something like:
plot(parta(:,1),parta(:,2));
MATLAB will create a line plot that connects each point in the order of the array element index (i.e., (x1,y1) to (x2,y2) even if (x3,y3) would be closer to (x1,y1) in a linear fit). I can't understand why this occurs, but I assume its related to the fact that I can't convert the table arrays.
1 answer

If you use xlsread with only 1 return argument as:
num = xlsread(filename, sheet);
,the return value will be numeric matrix, hence you cannot convert the numeric matrix using the cell2mat function. What you probably used before is:
[num, txt, raw] = xlsread(filename, sheet);
,which returns cell arrays for second and third return value, since
txt
will read all cells that contain only text data, and place it in cell matrix, andraw
will read all data, and again place it in cell matrix, mixing numbers and character arrays.