I have the following (simplified) data file:
# Created on Fri Aug 27 16:48:30 2021
# name: M
# type: matrix
# rows: 5
# columns: 5
0 0 0 0 0
0 5 0 0 0
0 4 0 0 0
0 4 0 0 0
0 4 0 0 0
0 1 0 0 0
1 0 1 0 0
0 5 0 0 0
0 4 0 0 0
0 4 0 0 0
0 1 0 0 0
1 1 1 0 0
1 0 1 0 0
0 5 0 0 0
0 4 0 0 0
0 1 0 0 0
1 1 1 0 0
1 1 1 0 0
1 0 1 0 0
0 5 0 0 0
I need to use GNU Octave to plot these data as a 2D XY surface and be able to scroll across the Z axis.
This is what I did so far:
clf;
colormap ("default");
# Load data file in matrix M
load "./toy.data"
# Axes range
x = 0:columns(M);
y = 0:rows(M);
h = imagesc (x, y, M);
The result is what I expect; the only issue is that only the first XY slice is shown.
How can I make Octave read the next blocks, and shown them when I press two keys or when I move the mouse pointer to go back and forth with respect to my actual position?
With Tasos suggestion, I updated the file which now includes a slider and a (still empty) callback:
clf;
colormap ("default");
# Load data file in matrix M
load "./toy.data"
# Axes range
x = 0:columns(M);
y = 0:rows(M);
h = imagesc (x, y, M);
%% Add ui 'slider' element
hslider = uicontrol ( ...
'style', 'slider', ...
'Units', 'normalized', ...
'position', [0.1, 0.1, 0.8, 0.1], ...
'min', 1, ...
'max', 5, ...
'value', 1, ...
'callback', {@updateTime} ...
);
%% Callback function called by slider event to change time frame
function updateTime (h, event)
%% TODO - Update CData
end