9778818威尼斯官网:有关多维数组取值的难点,达

首先要添加m_gshhs工具包,在private文件夹下下载好岸线数据,具体请参考m_map工具包官网

Matlab plotyy画双纵坐标图实例

x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');

set(AX(1),'XColor','k','YColor','b');
set(AX(2),'XColor','k','YColor','r');

HH1=get(AX(1),'Ylabel');
set(HH1,'String','Left Y-axis');
set(HH1,'color','b');

HH2=get(AX(2),'Ylabel');
set(HH2,'String','Right Y-axis');
set(HH2,'color','r');

set(H1,'LineStyle','-');
set(H1,'color','b');
set(H2,'LineStyle',':');
set(H2,'color','r');

legend([H1,H2],{'y1 = 200*exp(-0.05*x).*sin(x)';'y2 = 0.8*exp(-0.5*x).*sin(10*x)'});
xlabel('Zero to 20 musec.');
title('Labeling plotyy');

Q:右边用蓝色圈起来的tick能去掉吗?由于用plotyy画图,为了使图尽量地显示出来,用了set(AX(1),'YLimMode','auto'),但这样可能会导致左边AX(1)和右边AX(2)的tick的间距不一样,影响美观。或者说能不能使plotyy画出的图两边的tick间距是一样的,这样在图形右边的tick就会重合在一起.

A:如果只是想让plotyy的图美一些,可以使用其如下形式的调用方式:
[AX,H1,H2] = plotyy(...)
其中AX(2)就是右边Axes对象的句柄,拿到它以后就可以set或者get来处理了,也可以把其ytick关掉。

A:也可以用line语句来画,就没有左边和上边的线了。

Q:plotyy(X1,Y1,X2,Y2,FUN1,FUN2),FUN1和FUN2应该怎么写?

A:这两个FUN代表plotyy不一定要用两个plot,比如下面的例子,一条曲线用plot,一条用semilogy

x1=1:0.1:100;
x2=x1;
y1=x1;
y2=x2.^3;
plotyy(x1,y1,x2,y2,@plot,@semilogy)

C语言验证码的小问题 出不来 请各位指教
#9778818威尼斯官网:有关多维数组取值的难点,达成从一个类中调用二个值。include "stdio.h"
#include "string.h"
#include "time.h"
#include "stdlib.h"
void main()
{
char checkcode[63]={'q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m','Q','W','E','R','T','Y','U','I','O','P','A','S','D','F','G','H','J','K','L','Z','X','C','V','B','N','M','0','1','2','3','4','5','6','7','8','9'}
char ch[5];
srandtime;
for(int i=0;i<4;i )
{
int m=rand()b;
ch[i]=checkcode;
}
ch[i]='';
puts;
printf;
}

C#实现从一个类中调用一个值 5C
class phone
{
public char[] pHone1 = { 'a', 'b', 'c' };
public char[][]pHone = new char[][]{new char[3]{' ',' ',' '},new char[3]{' ',' ',' '},new char[3]{ 'a','b','c'},new char[3]{'d','e','f'},new char[3]{'g','h','i'},new char[3]{'j','k','l'},new char[3]{'m','n','o'},new char[4]{'p','q','r','s'},new char[3]{'t','u','v'},new char[4]{'w','x','y','z'}};
public string show
{
string num2="";
for (int i = 0; i < s.Length; i )
{
if (i % 2 == 0 && i != s.Length - 1)
num2 = pHone[s[i] - '0'][s[i 1] - '0'];
if (i == s.Length - 1 && i% 2 == 0)
num2 = tostring( pHone[s[i] - '0']);

关于多维数组取值的问题
public char[,]pHone = {{ 'a','b','c',' '},{'d','e','f',' '},{'g','h','i',' '},{'j','k','l',' '},{'m','n','o',' '},{'p','q','r','s'},{'t','u','v',' '},{'w','x','y','z'}};
怎么输出a,b,c

在m_gshhs.m下,告诉我们如何加入国界

来源:

 } return num2; } public string tostring(char [] b) {string num1=""; for(int i=0;i<b.Length;i  ) num1 = b[i]; return num1;} class morse 

function m_gshhs(resolution,varargin);


MATLAB画双纵坐标

 

具有两个纵坐标标度的图形  
在MATLAB中,如果需要绘制出具有不同纵坐标标度的两个图形,可以使用plotyy绘图函数。调用格式为:  
plotyy(x1,y1,x2,y2)  
其中x1,y1对应一条曲线,x2,y2对应另一条曲线。横坐标的标度相同,纵坐标有两个,左纵坐标用于x1,y1数据对,右纵坐标用于x2,y2数据对。

双y轴坐标可以用plotyy(x,y1,x,y2)来实现  
双x坐标可以用  
set(gca,'xaxislocation','bottom','xticklabel',{'0','1','2','3','4'})
(假设x轴的标注为1,2,3,4)  
set(gca,'xaxislocation','top','xticklabel',{'0','1','2','3','4'})  
进行相应的设置

【 * 例 10.7.3 -1
】制作一个双坐标系用来表现高压和低温两个不同量的过渡过程。

tp=(0:100)/100*5;yp=8 4*(1-exp(-0.8*tp).*cos(3*tp)); % 压力数据

tt=(0:500)/500*40;yt=120 40*(1-exp(-0.05*tt).*cos(tt)); % 温度数据

% 产生双坐标系图形

clf reset,h_ap=axes('Position',[0.13,0.13,0.7,0.75]); %&lt;4&gt;

set(h_ap,'Xcolor','b','Ycolor','b','Xlim',[0,5],'Ylim',[0,15]);

nx=10;ny=6; %&lt;6&gt;

pxtick=0:((5-0)/nx):5;pytick=0:((15-0)/ny):15; %&lt;7&gt;

set(h_ap,'Xtick',pxtick,'Ytick',pytick,'Xgrid','on','Ygrid','on')

h_linet=line(tp,yp,'Color','b'); %&lt;9&gt;

set(get(h_ap,'Xlabel'),'String',' 时间 /rightarrow (分) ')

set(get(h_ap,'Ylabel'),'String',' 压力 /rightarrow(/times10 ^{5} Pa )')

h_at=axes('Position',get(h_ap,'Position')); %&lt;12&gt;

set(h_at,'Color','none','Xcolor','r','Ycolor','r'); %&lt;13&gt;

set(h_at,'Xaxislocation','top') %&lt;14&gt;

set(h_at,'Yaxislocation','right','Ydir','rev') %&lt;15&gt;

set(get(h_at,'Xlabel'),'String','/fontsize{15}/fontname{ 隶书 } 时间
/rightarrow (分) ')

set(get(h_at,'Ylabel'),'String',' ( {/circ}C )/fontsize{15} /leftarrow
/fontname{ 隶书 } 零下温度 ')

set(h_at,'Ylim',[0,210]) %&lt;18&gt;

line(tt,yt,'Color','r','Parent',h_at) %&lt;19&gt;

xpm=get(h_at,'Xlim'); %&lt;20&gt;

txtick=xpm(1):((xpm(2)-xpm(1))/nx):xpm(2); %&lt;21&gt;

tytick=0:((210-0)/ny):210; %&lt;22&gt;

set(h_at,'Xtick',txtick,'Ytick',tytick) %&lt;23&gt;




来源:<http://hi.baidu.com/goodenoughcui/blog/item/e9a00b8b7ad52d6f9e2fb4d2.html>

~~~~

{
public string [] MORSE = {"-----","*----","**---","***--","****-","*****","-****","--***","---**","----*"};
public string initmorse;
public bool exam(string initmorse)

% First char: resolution - one of

实例(已验证):

{

% 'c' crude

clc;
clear all;
close all;
x=0:0.1:2*pi;
y1=sin(x);
y2=cos(x);
[AX]=plotyy(x,y1,x,y2);
set(get(gca,'xlabel'),'string','X-axis');
set(get(AX(1),'Ylabel'),'string','left Y-axis');
set(get(AX(2),'Ylabel'),'string','right Y-axis');
set(gca,'xTick',[0:0.5:7]);
set(AX(1),'yTick',[-1:0.2:1]);
set(AX(2),'yTick',[-1:0.5:1]);

for (int i = 0; i < initmorse.Length; i )
{
if (initmorse[i] == '*' || initmorse[i] == '-')
continue;
else
return true;
}
if (initmorse.Length % 5 == 0)
return !true;
else
return true;

% 'i' intermediate

 

}

% Second char: type - one of

尚存在问题:这种设置方法,对各个轴的最小刻度单位可以设置,但是刻度范围(x取(0~7),y1取(-1~1))不能设置。
2010-12-23修改

public void show()
{

% 'c' GSHHS coastline

 

 for( int index=0;index<=9;index  ) { Console.WriteLine("t{0}t{1}", index, MORSE[index]); }

% 'b' WDB Border

~~~~~~~~~~~~~~~~~~~~~~

}
public string explain(string initmorse)
{
string sum = "";
for (int i = 0; i < initmorse.Length; i )
{
if (i % 5 != 0)
continue;
string a;
a = initmorse[i].ToString() initmorse[i 1] initmorse[i 2] initmorse[i 3] initmorse[i 4];
int index = Array.IndexOf;

% 'r' WDB River

clc
clear all
close all
runoff=[10700 11400 15800 22900 43100 40700 50500 46000 41800 35000];
sed=[0.105 0.094 0.156 1.264  

 sum  = index; } return sum;} }

% Third char - if 2nd char is 'c':

 0.363 0.429 0.731 0.682 0.654 0.290];
m=1:10;
[ax,h1,h2]=plotyy(m,runoff,m,sed); %h-- line handle
set(get(ax(1),'Ylabel'),'string','Runoff (m^3/s))','color','r') %y1
set(get(ax(2),'Ylabel'),'string','Sediment concentration (kg/m^3)','color','k') %y2
xlabel('Month')
set(h1,'linestyle','-','color','r');   
set(h2,'linestyle','- -','color','k');
legend([h1 h2],'runoff','sediment concentration') %标注两条线
legend('boxoff')
% box off
set(ax(:),'Ycolor','k') %设定两个Y轴的颜色为黑色
set(ax(1),'ytick',[0:10000:100000]); %设置y轴间隔
set(ax(2),'ytick',[0:0.1:1.5])
set(ax,'xlim',[1 12]) % 设置x轴范围
hold on
scatter(ax(1),4,22900,'r*')
axes(ax(2));
hold on
scatter(4,1.264,'ro')

}
static void Main(string[] args)
{

% '1' Country borders

  

 Console.WriteLine("本程序可以实现的摩尔斯编码与解码"); Console.WriteLine("1.打印摩尔斯密码表"); Console.WriteLine("2.摩尔斯码编码"); Console.WriteLine("3.手机 按键编码"); Console.WriteLine; Console.WriteLine; Morse.show(); Console.WriteLine("请输入摩尔斯码:"); Morse.initmorse= Console.ReadLine(); while (Morse.exam(Morse.initmorse)) { Console.WriteLine("存在异常字符,或者符号个数不对,请重新输入:"); Morse.initmorse = Console.ReadLine(); } Console.WriteLine("解码数字为{0}", Morse.explain(Morse.initmorse)); // Console.WriteLine("解码数字为{0}",Morse.explain( Morse.initmorse)); phone Phone = new phone(); Phone.show(Morse.explain(Morse.initmorse)); Console.ReadLine(); }}

% '2' State/Province and Country borders

来源:

}
class qwe
{

% - if 2nd char is 'r': '1','2','3','4'

 

 } 以上是完整代码,我想把phone类中的num2用到qwe类中,听说实例化就可以做到,然后我就在qwe类用中用 Phone.show(Morse.explain(Morse.initmorse)); ,但是报错了

% add successively more tributaries

2011年4月22日新增

m_gshhs_h('patch',[0.7 0.7 0.7],'Edgecolor','none');% 加阴影陆地,岸线不加

 

m_gshhs('hc1','linewidth',.8,'color','k');% 只加岸线国界线

m_gshhs('hb1','linewidth',.8,'color','k');% 陆地国界线

本文由9778818威尼斯官网发布于9778818威尼斯官网,转载请注明出处:9778818威尼斯官网:有关多维数组取值的难点,达

您可能还会对下面的文章感兴趣: