quiver plot - need help to remove NaN
古いコメントを表示
Hi all,
Thanks for your time reading this. I have some trouble to remove NaN values from my quiver plot. I've tried to replace them with zero but it didn't work too.
U(isnan(U))= 0;
Also, I've tried with index and replace it in quiver plot, with this I managed to remove the NaN values but I ended up plotted massive vectors which I don't know how to make them less dense without losing their original information.
idx = ~isnan(U) & ~isnan(V);
quiver(Xp(idx),Yp(idx),U(idx)),V(idx))
I'm not very sure what is a better way to plot them but I prefer not to scale my vector arrows to keep the original information. My script and a screenshot of my plot as follow where you can see black dotes on the land areas (Ireland, the UK and Europe) - this is a result from my SWAN wave model (0.05degree resolution). I want to remove those black dotes. Hope someone can help me. All my variables are in matrix (i.e 461x401) as attached. Sorry, I'm a new Matlab user. Thanks in advance!
figure
contourf(Xp,Yp,Hs,'LineColor','none');
caxis([0,10]);
colormap (jet);
colorbar
hold on;
quiver(Xp(1:15:end,1:15:end),Yp(1:15:end,1:15:end),U(1:15:end,1:15:end)),V(1:15:end,1:15:end)),...
'LineWidth',1,'Color','k') % plot for bigger size and less dense arrows

Thanks, Raydo
4 件のコメント
Andrew Reibold
2014 年 11 月 14 日
Removing the black dots in the white areas is all you want to do?
Raydo Eugov
2014 年 11 月 18 日
Giorgos Papakonstantinou
2014 年 11 月 18 日
編集済み: Giorgos Papakonstantinou
2014 年 11 月 19 日
The Code button formats the code part in your answer. It is very easy to use this tool. You just highlight the code and you press the button. It improves the readability for someone who reads your question.
Andrew Reibold
2014 年 11 月 18 日
The code you provided produce a different plot for me with the attached data

I solved your issue for the plot below, see in the answers section. Let me know if your problem is resolved.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Vector Fields についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
