I'd like to draw 2D image with excel file data

Hi, I'd like to draw 2D image by matlab.
I have excel file like below image.
Each value means weight(simply, power) of the photon, and I want to draw it by 2D image with different color(following value of weight).
For example, blank of 0.4 has yellow or orange color and blank of 0.9 has red color in 2D image.
Thanks a lot.

Answers (2)

Stephan
Stephan on 12 Nov 2020
Edited: Stephan on 13 Nov 2020
% Enter filename + path here:
filename = 'basic_matrix.xls'
% Get data from excel into array
M = readmatrix(filename);
% plot values
contourf(-M)
% use colormap with needed color scheme
colormap(autumn)

5 Comments

Thanks for your reply. The code said 'readmatrix' is not defined.
Stephan
Stephan on 13 Nov 2020
Edited: Stephan on 13 Nov 2020
Which release do you use?
I'm sorry, but I cannot understand your question. I'm novice at Matlab...sorry. I just tried to use your code as it is.
Which Matlab release (=Version) do you use? Try xlsread instead:
% Enter filename + path here:
filename = 'basic_matrix.xls'
% Get data from excel into array
M = xlsread(filename);
% plot values
contourf(-M)
% use colormap with needed color scheme
colormap(autumn)
Oh, I use R2017b, and it also said error...I named file which locates on exact folder, but it said it cannot find the file. Sorry for bothering you.

Sign in to comment.

You can try this command:
z=xlsread("YourExcelFile.xlsx");
surf(z);
You can ajust the image details, eg. axes names and color scale, on the figure.

Categories

Tags

Asked:

on 12 Nov 2020

Answered:

on 3 Mar 2022

Community Treasure Hunt

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

Start Hunting!