0

I want to create an image like the one below, based on a specific matrix where 4 is green, 3 is blue, 2 is yellow and 1 is red.

The image would be 18 columns and 22 rows and the data would be uploaded using a txt file. The data would be between 4-1 and be automatically color coded once the file is ran

image example matrix

I was referencing this code from here for help Plot a matrix, values as colors but I am confused on how to go about fixing the loop and integrating a text file instead of an actual random matrix. any assistance or guidance would be appreciated

Prayer
  • 9
  • 1
  • 1
    [importdata](https://ww2.mathworks.cn/help/matlab/ref/importdata.html?lang=en), [colormap](https://ww2.mathworks.cn/help/matlab/ref/colormap.html?lang=en), [imagesc](https://ww2.mathworks.cn/help/matlab/ref/imagesc.html?lang=en) – X Zhang Jan 20 '22 at 02:09
  • So your question boils down to "How do I read a file into a MATLAB matrix?", right? Because after that, Luis' answer on the post you linked will function the exact same. As wwweagle said, use `importdata` to actually import a file. – Adriaan Jan 20 '22 at 08:01

0 Answers0