Use Excel columns as X Y cell coordinates to look up Z values from matrix

3 ビュー (過去 30 日間)
Peter Dorofy
Peter Dorofy 2015 年 10 月 19 日
回答済み: TastyPastry 2015 年 10 月 19 日
Hello,
I have imported an excel spreadsheet where column A are X coordinates and column B are Y coordinates
example:
Column A: 2,4,6,8, ... X
Column B: 1,3,4,7, ... Y
I have a large 2000x1000 matrix where each cell has some Z value. I need to be able to extract the Z values from the matrix using the X Y coordinates imported from Excel. Ultimately I will be exporting a third column C which contains those Z values back to excel. Below is what I have, but not sure where to go from here:
X = xlsread('data.xlsx','A1:A100');
Y = xlsread('data.xlsx','B1:B100');
I need to lookup and store the Z values of those 100 data points from the 2000x1000 matrix. It sounds like it should be simple, but somehow I am missing something. Any suggestions?
Thanks,
-Peter

回答 (1 件)

TastyPastry
TastyPastry 2015 年 10 月 19 日
myVals = diag(z(X,Y));

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by