surf() cannot draws arrays of characters. You would need to convert the characters to numbers first. That is going to be tricky for you because MATLAB numeric arrays cannot have "holes" in them.
The loop
for r=1:23
for n=1:23
if r==n
z1(r,n)=Z1(r,n);
else
z1(r,n)=NaN;
end
end
end
is equivalent to
z1 = nan(23,23));
z1(1:24:end) = diag(Z1(1:23,1:23));
which copies just the diagonal and sets all of the other elements to NaN.
This is a problem for surf(), because surf() determines the color of each face by calculating the average of the four surrounding vertices. Since only the diagonal is not nan, you can be certain that at least two of the four surrounding vertices of any face will be nan, so you can be certain that the value determined for each location will be nan, so the surf() is going to come up empty.
The arrays you show do not contain data for line plots: they contain one x, y, z coordinate per point, and the points are not ordered. Perhaps you want each point to be represented as a vector originating at (0, 0, 0) and terminating at the x, y, z coordinates?
Best Answer