storing value from a cell in an excel sheet

2 views (last 30 days)
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

Answers (2)

Dyuman Joshi
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')

Image Analyst
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:
  1 Comment
Arkadip Khan
Arkadip Khan on 16 Jan 2023
Hey, yeah I'm so sorry my question was so patchy and with any info at all, yes you are right geometric constants is the name of my workbook file and crb is the sheet name, i definetly do need a tutorial to learn how to ask a question so sorry for my incompetence.
coming to the question yes the value i want to store in my variable is no., will give it a shot with readmatrix and update you, thankyou so much for replying to such an awfully put question.

Sign in to comment.

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!