readcell command doesn't work anymore!
31 views (last 30 days)
Show older comments
Hi all,
I have a matlab code that reads data from an excel sheet using the readcell function.
I have a data starting in cell B3 to Bx (x can be different).
So I used the following finction to get these data
x1 = readcell("model","sheet","sheet name","Range",'B3:B3');
This function used to give me the needed results (all non empty cells in col B starting from B3). However, I just tried to run my code again today and I was chocked that this command doesn't work anymore!!! error !!!
any idea? please help me!
Thanks in advance,
Lara
4 Comments
Accepted Answer
Stephen23
on 23 Mar 2020
Edited: Stephen23
on 23 Mar 2020
This only reads one cell:
"Range",'B3:B3'
There is nothing in your code that reads "all non empty cells in col B starting from B3" as you write. It just reads B3.
6 Comments
NAFTALI HERSCOVICI
on 8 Jun 2022
is there a way to use cell numbers to specify a a range?
Like [2 3] instead of 'B3'.
I tried x1 = readcell("model","sheet","Global FCM","Range",[2 3]); and got the error "Unable to determine range".
Is this a syntax problem or simply cannot be done?
Stephen23
on 8 Jun 2022
Edited: Stephen23
on 8 Jun 2022
"is there a way to use cell numbers to specify a a range?"
Yes, according to the documentation the current READCELL permits a 2-element (start cell) and 4-element (start and end cells) numeric vectors for the RANGE option:
"Is this a syntax problem or simply cannot be done?"
It can be done. Lets try it here (sample file is attached, with UsedRange from A1 to C3):
C = readcell('test.xlsx','Range',[2,2])
That gives exactly the expected output without error.
The error message you showed sounds like there is some ambiguity with your worksheet. But if you do not upload a sample workbook by clicking the paperclip button then I cannot debug this for you.
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!