storing value from a cell in an excel sheet
2 views (last 30 days)
Show older comments
R1=xlsread('Geometric constants.xlsx','CRB','B2');
S1=xlsread('Geometric constants.xlsx','CRB','C2');
% this give me error
%so here geometric constants is the name of my sheet
%CRB the name of my sheet
%B2 the cell value
%is there an alternate way to read and store a cell value in my variable
0 Comments
Answers (2)
Dyuman Joshi
on 15 Jan 2023
Moved: Image Analyst
on 15 Jan 2023
Try this
R1=readmatrix('Geometric constants.xlsx','Sheet','CRB','Range','B2')
S1=readmatrix('Geometric constants.xlsx','Sheet','CRB','Range','C2')
0 Comments
Image Analyst
on 15 Jan 2023
You forgot to attach the workbooks. Make it easy for us to help you, not hard.
You can use readmatrix if the values are numbers. If the values are strings, then you should use readcell instead.
You said "geometric constants is the name of my sheet" but did you really mean "geometric constants is the name of my workbook file"? Because you're telling xlsread that CRB is the name of the sheet, not "geometric constants"
Finally, you also forgot to tell us what the error actually was. The code looks correct so I don't know what the error message is since my Crystal Ball Toolbox is still on back order.
If you have any more questions, then attach your workbook file with the paperclip icon after you read this:
See Also
Categories
Find more on Matrix Indexing 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!