Matlab 2013a and Excel

I am using Matlab 2013 a and I have an excel sheet that has 2D numerical values. For e.g:
-3 -2 -1 0 1 2 3
0 2.1 5 4 2.5 3 8 9
-1 11 12 13 9 4 2 1
and so on, I would like to know how I can get a certain cell value such as '13' as an e.g. from the values (-1,-1), what function i can use and how. thanks in advance.

5 Comments

yes I use xlsread to read the excel sheet but hw I can get a certain cell from 2 points?
this worked very well in matlab script, but when I used in smiling as matlab function. it keeps getting me errors.
data = [3.73 4.46 4.95 6.58 7.74 9.56 11.13 12.82 17.13 22.91 27.51 29.63 24.54 19.65 15.30 12.69 9.43 8.63 7.07 6.07 4.96;5.05 5.79 6.88 8.66 10.25 13.07 16.41 20.35 24.85 27.83 23.44 27.05 23.07 18.40 14.76 12.00 9.78 8.05 6.48 5.37 4.57;4.44 5.81 6.72 7.76 9.47 11.30 15.16 18.22 22.08 24.05 24.42 23.16 19.49 15.96 13.80 11.27 9.43 7.61 6.27 5.04 4.45;4.081666326 5.107837116 5.568662317 6.414047084 6.970652767 7.816009212 9.513148795 13.34578585 15.19243233 17.17934807 17.08478856 16.59698768 15.14100393 13.10305308 11.60129303 9.196194865 7.794228634 6.62495283 5.525395913 4.868264578 4.009987531;4.00 3.99 4.76 5.45 6.50 8.71 8.80 9.58 10.57 11.08 11.26 11.06 10.56 9.14 8.15 7.38 6.07 5.73 4.79 4.21 2.34;3.09 3.28 3.96 4.28 5.39 5.57 6.39 6.97 7.46 7.70 8.54 8.17 7.53 6.82 6.31 5.59 4.93 4.42 3.97 3.20 3.07;2.780287755 2.952964612 3.367491648 3.734969879 4.125530269 4.7138095 5.269724851 5.427706698 5.675385449 5.936328832 5.98414572 5.81119609 5.683308895 5.378661544 4.996999099 4.673328578 3.97743636 3.689173349 3.2984845 2.870540019 2.601922366;2.30 2.53 2.81 3.18 3.48 3.56 3.83 3.97 4.16 4.26 4.33 4.15 4.03 3.80 3.64 3.36 3.15 2.95 2.71 2.44 2.15;1.87 2.01 2.20 2.48 2.53 2.66 2.91 3.00 3.10 3.08 3.01 3.10 3.02 2.97 2.85 2.69 2.46 2.34 2.12 1.95 1.89;];
row = [0;-0.2;-0.5;-0.8;-1.1;-1.4;-2;-2.5;-3];
column = [3 2.7 2.4 2.1 1.8 1.5 1.2 0.9 0.6 0.3 0 -0.3 -0.6 -0.9 -1.2 -1.5 -1.8 -2.1 -2.4 -2.7 -3];
Bt = data(row==z,column==x);
Never write "not working" without telling in what way and providing an error message.
data seems to be a row vector. What does
whos data
show?
how can I plot these data plot(z,x,Bt) ????

Sign in to comment.

Answers (2)

Assumption:
  • the values in the top row are unique integers
  • the values in the leftest column are unique integers
Hint:
data = [ 2.1 5 4 2.5 3 8 9
11 12 13 9 4 2 1 ];
row_points = [ 0; -1 ];
col_points = [ -3 -2 -1 0 1 2 3 ];
data( row_points==-1, col_points==-1 )
returns
ans =
13

8 Comments

function Bt = fcn(x,z)
%#codegen
coder.extrinsic('xlsread');
data = xlsread('Coil2D.xlsx','Sheet3');
Bt = zeros(21,21);
row = [0;-0.2;-0.5;-0.8;-1.1;-1.4;-2;-2.5;-3];
column = [3 2.7 2.4 2.1 1.8 1.5 1.2 0.9 0.6 0.3 0 -0.3 -0.6 -0.9 -1.2 -1.5 -1.8 -2.1 -2.4 -2.7 -3];
Bt = data(row==z,column==x);
Why this is not working? in Simulink however well on matlab script
Never write "not working" without telling in what way and providing an error message.
Subscripting into an mxArray is not supported. Please reply this. thanks
Errors occurred during parsing of MATLAB function 'MATLAB Function1'(#64)
what is the zeros(m,n) function means and what are the m and n?
whos data; whos data; Name Size Bytes Class Attributes
data 9x21 1512 double
I know the output is gonna be a scalar integer 1*1.
how can I plot(data(row_points,column_points) with row_points and column_points?

Sign in to comment.

if this is your excel data(say)
-3 -2 -1 0 1 2 3
0 2.1 5 4 2.5 3 8
-1 11 12 13 9 4 2
num = xlsread('cloudy.xlsx');
value=num(2,2); %for value Of B2 in excel
the value will be 2.1

2 Comments

Subscripting into an mxArray is not supported.
please clarify your comment

Sign in to comment.

Categories

Products

Asked:

on 2 Apr 2015

Commented:

on 28 Apr 2015

Community Treasure Hunt

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

Start Hunting!