Question: MATLAB MATLAB MATLAB function [ Topograph , lowHighDist ] = generateTopographicalMap ( Altitude , Water ) [ m , n ] = size ( Altitude

MATLAB MATLAB MATLAB
function [Topograph, lowHighDist]= generateTopographicalMap(Altitude, Water)
[m, n]= size(Altitude);
Topograph = zeros(m, n,3, 'uint8');
colors =[
0,0,255; % Blue (Water)
0,0,0; % Black (Below Sea Level)
0,255,0; % Green (Up to 1000 meters)
255,255,0; % Yellow (1000 to 2000 meters)
255,165,0; % Orange (2000 to 3000 meters)
255,0,0; % Red (3000 to 4000 meters)
255,255,255;% White (4000 to 4500 meters)
0,255,255% Cyan (Above 4500 meters)
];
land = Altitude .*(~Water);
maxAlt = max(land(:));
minAlt = min(land(land >0));
[maxRow, maxCol]= find(land == maxAlt);
[minRow, minCol]= find(land == minAlt);
lowHighDist = sqrt((maxRow - minRow).^2+(maxCol - minCol).^2)*10;
for i =1:m
for j =1:n
if Water(i, j)==1
Topograph(i, j, :) = colors(1, :); % Blue
elseif Altitude(i, j)<0
Topograph(i, j, :) = colors(2, :); % Black
elseif Altitude(i, j)<=1000
Topograph(i, j, :) = colors(3, :); % Green
elseif Altitude(i, j)<=2000
Topograph(i, j, :) = colors(4, :); % Yellow
elseif Altitude(i, j)<=3000
Topograph(i, j, :) = colors(5, :); % Orange
elseif Altitude(i, j)<=4000
Topograph(i, j, :) = colors(6, :); % Red
elseif Altitude(i, j)<=4500
Topograph(i, j, :) = colors(7, :); % White
else
Topograph(i, j, :) = colors(8, :); % Cyan
end
end
end
Topograph(maxRow, maxCol, :) =[255,0,255]; % Magenta
Topograph(minRow, minCol, :) =[128,0,128]; % Purple
end
% Running Code:
Altitude = readmatrix("C-alts.csv");
Water = readmatrix("C-water.csv");
[Topograph, lowHighDist]= generateTopographicalMap(Altitude, Water);
image(Topograph);
**Error***
Unable to perform assignment because the size of the left side is 47-by-47-by-3 and the size of the
right side is 1-by-3.
Error in Project1>generateTopographicalMap (line 65)
Topograph(minRow, minCol, :) =[128,0,128]; % Purple
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in Project1(line 76)
[Topograph, lowHighDist]= generateTopographicalMap(Altitude, Water);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
Can anyone help me with this code?
csv files are 107 x 128 doubles.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!