MATLAB: Importing excel data containing previously defined variables

excel import

I have a sheet of excel data which contains variables such as x and y. Is there a way to, given the data is defined in the MATLAB workspace, print an array of values based on what x and y are?
x=5;
y=6;
A=[1 2 4 x 8 y 10]; % input
%%PROCESS
B=[1 2 4 5 8 6 10]; % output

Best Answer

I think the script like this can do what you want.
% Read excel file
[A,~,raw] = xlsread('yourExcel.xlsx');
% Variables
x = 5;
y = 6;
% Replace 'x' and 'y'
idx = strcmp(raw,'x');
A(idx) = x;
idx = strcmp(raw,'y');
A(idx) = y;
And here is the assumed 'yourExcel.xlsx'