Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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?

Antworten (1)

Dave Behera
Dave Behera am 21 Mär. 2016
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.

Community Treasure Hunt

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

Start Hunting!

Translated by