(Xlsread) Quick Question: How to compare multiple columns that are not next to each other?

4 ビュー (過去 30 日間)
Adrian Valdivia Portilla
Adrian Valdivia Portilla 2016 年 3 月 16 日
回答済み: Dave Behera 2016 年 3 月 21 日
Keep in mind I can only use basic MATLAB commands because I am just starting out in my class Is it possible to add multiple ranges to the code so it pulls columns that aren't next to each other in excel? My excel doc is very simple only being 6 columns but I want it to compare them side by side.
This is what I have so far:
cars = input('Type in the 2 cars in the format of 12, 21, 35, 51 - in any order: ');
if (cars == 12 || cars == 21)
disp('You have chosen to compare the Bentley and the Audi!');
[~,~,raw]=xlsread('cars.xlsx','A1:C8');
disp(raw)
elseif (cars == 13 || cars == 31)
disp('You have chosen to compare the Bentley and the BMW!');
[~,~,raw]=xlsread('cars.xlsx', 'A1:B8', 'D:D')
disp(raw)
The end of it where I have 'A1:B8', 'D:D' is incorrect as it doesn't dipslay what I want it to
Help?

回答 (1 件)

Dave Behera
Dave Behera 2016 年 3 月 21 日
Hi Adrian,
To use xlsread, you must specify a rectangular area in your xls file to be read. Having columns which are not next to each other does not satisfy this criteria. Therefore, you will need to read both columns separately and combine the resulting matrices in order to get the combined data.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by