Surf with shading interp, not interpolating sometimes.

110 次查看(过去 30 天)
So I am trying to plot waveform data both as lines (using plot3) and also as a smoothed color connecting the waveform using surf and shading interp (see picture). In the image it looks correct between ~135 and 215 on the x-axis and between ~230 and 245, but I don't understand the gap between ~215 and 230, and after 245.
Basically the question is why is it interpolating between 135-215 but not between 213-230?
Here is the plotting section of my script. The sizes of all the plotting variables is 1200 x 578. They are mostly columns of nan becasue prior to plotting I filter out unwanted columns and replace them with nan.
To recreate this, load the .mat file and run this code:
loat 'ex.mat'
figure(1)
hold on
plot3(baz_amps, times,repmat(2,1200,578),'k','Linewidth', .1)
caxis([-.25 .25])
colormap(redblue)
surf(baz_list,times,Amps)
shading interp
view(2)
colorbar
ylim([0 35])
xlim([min(min(baz_list))-5 max(max(baz_list))+5])
Hopefully that works. Side note, I am using R2014a.
Thanks for any help

回答(1 个)

Kris Fedorenko
Kris Fedorenko 2017-9-6
Hi!
I believe the issue is with the NaN values. The shading interp command only dictates how the colors are shown for the existing datapoints, but does not fill in NaN values. In fact, any NaN values are explicitly not plotted. I see that your data has only 14 columns of non-NaN values, so I think what you want is to get rid of the NaN columns altogether. For example:
load 'ex.mat'
nRows = size(Amps, 1);
nan_cols = sum(isnan(Amps)) == nRows;
Amps(:, nan_cols) = [];
nan_cols = sum(isnan(baz_amps)) == nRows;
baz_amps(:, nan_cols) = [];
nan_cols = sum(isnan(times)) == nRows;
times(:, nan_cols) = [];
nan_cols = sum(isnan(baz_list)) == nRows;
baz_list(:, nan_cols) = [];
nCols = size(Amps, 2);
figure;
hold on
plot3(baz_amps, times,repmat(2,nRows, nCols),'k','Linewidth', .1)
caxis([-.25 .25])
colormap(cool)
surf(baz_list,times,Amps)
shading interp
view(2)
colorbar
ylim([0 35])
xlim([min(min(baz_list))-5 max(max(baz_list))+5])
xlabel('baz amps')
ylabel('times')
zlabel('Amps')
This code should produce a plot like this one:
Hope this helps!
Kris

类别

Help CenterFile Exchange 中查找有关 Orange 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by