flipud will not work anymore

7 ビュー (過去 30 日間)
Vince Clementi
Vince Clementi 2017 年 9 月 18 日
コメント済み: Steven Lord 2017 年 9 月 26 日
Hi all,
I am creating a global map and using the cmocean colorbar options. I need to show depth below sea level, so for a few of the color options, I need to invert the colorbar direction. I did this a few months ago using the 'flipud' function and it worked flawlessly. However, I am trying to do the same thing again and it will not work. Am I missing something (code below)? Thanks!
[Z, refvec] = etopo('etopo1_ice_c_i2.bin', samplefactor);
geoshow(Z, refvec, 'DisplayType', 'surface');
setm(gca,'mapprojection','mercator');
cmap = cmocean(flipud('deep'),'5');
demcmap(Z, 256, cmap, [.25 .25 .25]);
colorbar;
c = colorbar
title(c,'m','FontSize',12);
set(c, 'ylim', [-10000 0]);

採用された回答

Chad Greene
Chad Greene 2017 年 9 月 26 日
The simplest solution is to use the - sign when calling cmocean. So instead of
cmap = cmocean('deep','5');
use
cmap = cmocean('-deep','5');

その他の回答 (2 件)

Henry Giddens
Henry Giddens 2017 年 9 月 18 日
It looks like you are calling flipud on the string 'deep', which will return the string 'deep'. I dont know what you cmocean command does (I am guessing it returns a colormap with 5 rows), but it looks like you may want to change this line to:
cmap = flipud(cmocean('deep','5'));

Walter Roberson
Walter Roberson 2017 年 9 月 18 日
flipud('deep') means the same as flipud(['d', 'e', 'e', 'p']) which is asking to flip a 1 x 4 char array upside down, which would get you the same array ['d', 'e', 'e', 'p']
  2 件のコメント
James Tursa
James Tursa 2017 年 9 月 26 日
So ... you wouldn't get 'peed'?
Steven Lord
Steven Lord 2017 年 9 月 26 日
Of course not.
Now if you had called fliplr or flip instead ... :)
>> fliplr('deep')
ans =
'peed'
>> flip('deep')
ans =
'peed'

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRed についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by