Remove single quotes around numeric vector

3 ビュー (過去 30 日間)
Chaimaa El
Chaimaa El 2022 年 6 月 20 日
コメント済み: Chaimaa El 2022 年 6 月 20 日
Hey,
I am using readcell to read some specific cells from an excel file, except that to specify the range I am using a four element numeric vector:
Example: X=readcell('C:\Users\pc\Desktop\MyFile.xlsx','Sheet',1,'Range',[752 4 752 4]); ==> X gets the content of the cell D752
And since that I have a large file and I want to read many cells that belongs to the same row but not the same columns, I am using the following loop:
for i=2:numel(MTnumbers)
if MTnumbers{1,i}==Machine{1,1}
RangeVector=sprintf('[752 %d 752 %d]',i,i); X=readcell('C:\Users\pc\Desktop\MyFile.xlsx','Sheet',1,'Range',VectorRange);
end
end
But this is not working because:
RangeVector='[752 2 752 2]' , while that the range value should not be between single quotes in readcell.
How can I remove the single quotes around the numeric vector? Do I have to use another function rather than sprintf?
Thank you,

採用された回答

Stephen23
Stephen23 2022 年 6 月 20 日
編集済み: Stephen23 2022 年 6 月 20 日
"Do I have to use another function rather than sprintf?"
Get rid of SPRINTF(), converting to character does not help you:
RangeVector = [752,i,752,i]; % basic MATLAB numeric vector
  1 件のコメント
Chaimaa El
Chaimaa El 2022 年 6 月 20 日
It's working. Thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by