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 commentaires

per isakson
per isakson le 2 Avr 2015
Marcos Tawadros
Marcos Tawadros le 2 Avr 2015
yes I use xlsread to read the excel sheet but hw I can get a certain cell from 2 points?
Marcos Tawadros
Marcos Tawadros le 3 Avr 2015
Modifié(e) : per isakson le 3 Avr 2015
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?
Marcos Tawadros
Marcos Tawadros le 28 Avr 2015
how can I plot these data plot(z,x,Bt) ????

Connectez-vous pour commenter.

Réponses (2)

per isakson
per isakson le 2 Avr 2015

0 votes

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 commentaires

Marcos Tawadros
Marcos Tawadros le 3 Avr 2015
Modifié(e) : per isakson le 3 Avr 2015
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
per isakson
per isakson le 3 Avr 2015
Never write "not working" without telling in what way and providing an error message.
Marcos Tawadros
Marcos Tawadros le 3 Avr 2015
Subscripting into an mxArray is not supported. Please reply this. thanks
Marcos Tawadros
Marcos Tawadros le 3 Avr 2015
Errors occurred during parsing of MATLAB function 'MATLAB Function1'(#64)
Marcos Tawadros
Marcos Tawadros le 3 Avr 2015
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
Marcos Tawadros
Marcos Tawadros le 3 Avr 2015
I know the output is gonna be a scalar integer 1*1.
Marcos Tawadros
Marcos Tawadros le 28 Avr 2015
how can I plot(data(row_points,column_points) with row_points and column_points?

Connectez-vous pour commenter.

LUI PAUL
LUI PAUL le 3 Avr 2015

0 votes

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 commentaires

Marcos Tawadros
Marcos Tawadros le 3 Avr 2015
Subscripting into an mxArray is not supported.
LUI PAUL
LUI PAUL le 5 Avr 2015
please clarify your comment

Connectez-vous pour commenter.

Catégories

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by