Index in position 1 is invalid. Array indices must be positive integers or logical values.
I am trying to take raw data from a zip file and the raw data includes x,y,z coordinates of each pixel in addition to the grayscale value (a measure of brightness/darkness of each pixel with lower values indicating darker pixel). The end result show be a clear xray. Here is what I have so far, but when I get to the for loop, I get an error of "Index in position 1 is invalid. Array indices must be positive integers or logical values."
How do I fix this?
image_data = readmatrix(‘Chest_Xray_Raw_Data.txt’);
x = data(:, 1);
y = data(:, 2);
z = data(:, 3);
grayscale_value = data(:, 4);
max_x = max(x);
max_y = max(y);
max_z = max(z);
max_grayscale = max(grayscale_value);
[max_y, max_x]
image_matrix = zeros(uint8(max_y), uint8(max_x));
for i = 1:length(grayscale_value)
image_matrix(y(i), x(i))= grayscale_value(i);
endI am trying to take raw data from a zip file and the raw data includes x,y,z coordinates of each pixel in addition to the grayscale value (a measure of brightness/darkness of each pixel with lower values indicating darker pixel). The end result show be a clear xray. Here is what I have so far, but when I get to the for loop, I get an error of "Index in position 1 is invalid. Array indices must be positive integers or logical values."
How do I fix this?
image_data = readmatrix(‘Chest_Xray_Raw_Data.txt’);
x = data(:, 1);
y = data(:, 2);
z = data(:, 3);
grayscale_value = data(:, 4);
max_x = max(x);
max_y = max(y);
max_z = max(z);
max_grayscale = max(grayscale_value);
[max_y, max_x]
image_matrix = zeros(uint8(max_y), uint8(max_x));
for i = 1:length(grayscale_value)
image_matrix(y(i), x(i))= grayscale_value(i);
end I am trying to take raw data from a zip file and the raw data includes x,y,z coordinates of each pixel in addition to the grayscale value (a measure of brightness/darkness of each pixel with lower values indicating darker pixel). The end result show be a clear xray. Here is what I have so far, but when I get to the for loop, I get an error of "Index in position 1 is invalid. Array indices must be positive integers or logical values."
How do I fix this?
image_data = readmatrix(‘Chest_Xray_Raw_Data.txt’);
x = data(:, 1);
y = data(:, 2);
z = data(:, 3);
grayscale_value = data(:, 4);
max_x = max(x);
max_y = max(y);
max_z = max(z);
max_grayscale = max(grayscale_value);
[max_y, max_x]
image_matrix = zeros(uint8(max_y), uint8(max_x));
for i = 1:length(grayscale_value)
image_matrix(y(i), x(i))= grayscale_value(i);
end index, greyscale, readmatrix MATLAB Answers — New Questions