MATLAB/Octave - Problems with mesh plot
I am trying to mesh the following function in Octave:
function C = istep(x)
A = x < 0.75
B = x > 0.25
C = A & B
endfunction
D = rand(10);
mesh(istep(D));
using 10x10 (random) matrix as an input. The mesh function however fails
and fires
invalid value for array property "zdata"
Note: Meshing D itself works fine. The function istep also returns 10x10
"matrix" with expected values. I suspect the error lies in the fact that
the internal format of the output is not treated as a matrix, but rather
as a data "array" or something more abstract. I am not sure how to change
it however.
Also, multiplying the output by eye(size(D)) solves the issue and allows
to plot the matrix (i suspect it casts the output to matrix
automatically). I do not find this very elegant though and would like to
avoid it if possible.
Edit: spy() works fine directly on the output, without need of
multiplication by eye()
Question: What shall I change in the code so I am able to plot the matrix
istep(D)?
No comments:
Post a Comment