24小时热门版块排行榜    

查看: 1578  |  回复: 3

lixixiao2

铜虫 (小有名气)

[求助] matlab surf函数的使用

y(i,j)是一个600*3600的矩阵,已经求解出来了,希望用surf函数,将i,j作为函数y的两个自变量表示成图形输出出来,求大神相助。
这是我写的语句:
[i,j]=meshgrid(1:600,1:3600);
for i=1:600
    for j=1:3600
z(i,j)=y(i,j);
    end
end
surf(i,j,z)
但错误很多,运行matlab提示:
??? Error using ==> surf at 78
Data dimensions must agree.

Error in ==> DEEuler at 73
surf(i,j,z)

[ Last edited by lixixiao2 on 2012-10-17 at 10:36 ]
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

navolo

木虫 (正式写手)

【答案】应助回帖

你的矩阵维数不一致,
关于surf命令与mesh使用类似,你可以看下帮助help surf

help surf
SURF   3-D colored surface.
    SURF(X,Y,Z,C) plots the colored parametric surface defined by
    four matrix arguments.  The view point is specified by VIEW.
    The axis labels are determined by the range of X, Y and Z,
    or by the current setting of AXIS.  The color scaling is determined
    by the range of C, or by the current setting of CAXIS.  The scaled
    color values are used as indices into the current COLORMAP.
    The shading model is set by SHADING.

    SURF(X,Y,Z) uses C = Z, so color is proportional to surface height.

    SURF(x,y,Z) and SURF(x,y,Z,C), with two vector arguments replacing
    the first two matrix arguments, must have length(x) = n and
    length(y) = m where [m,n] = size(Z).  In this case, the vertices
    of the surface patches are the triples (x(j), y(i), Z(i,j)).
    Note that x corresponds to the columns of Z and y corresponds to
    the rows.

    SURF(Z) and SURF(Z,C) use x = 1:n and y = 1:m.  In this case,
    the height, Z, is a single-valued function, defined over a
    geometrically rectangular grid.

    SURF(...,'PropertyName',PropertyValue,...) sets the value of the
    specified surface property.  Multiple property values can be set
    with a single statement.

    SURF(AX,...) plots into AX instead of GCA.

    SURF returns a handle to a surface plot object.

    AXIS, CAXIS, COLORMAP, HOLD, SHADING and VIEW set figure, axes, and
    surface properties which affect the display of the surface.

    Backwards compatibility
    SURF('v6',...) creates a surface object instead of a surface plot
    object for compatibility with MATLAB 6.5 and earlier.
   
    See also surfc, surfl, mesh, shading.

    Overloaded functions or methods (ones with the same name in other directories)
       help sweepset/surf.m

    Reference page in Help browser
       doc surf
2楼2012-10-30 22:07:50
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wurongjun

专家顾问 (职业作家)

【答案】应助回帖

★ ★ ★
lixixiao2: 金币+3, ★★★很有帮助 2012-11-02 09:39:54
没有大的错误!
不过是:i,j这两个变量已经在织网时用过了,后面循环再用就出错了!
           如果Y(i,j)知道直接用suf(i,j,y)就可以,不用赋值给z!
善恶到头终有报,人间正道是沧桑.
3楼2012-10-30 22:25:41
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zsy312

银虫 (小有名气)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★
lixixiao2: 金币+7, ★★★★★最佳答案 2012-11-05 16:55:29
CODE:
[i,j]=meshgrid(1:600,1:3600);
for i=1:600
    for j=1:3600
z(i,j)=y(i,j);
    end
end
i=1:600;
j=1:3600;
surf(i,j,z)

4楼2012-11-04 11:45:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 lixixiao2 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 材料与化工一志愿南昌大学327求调剂推荐 +7 Ncdx123456 2026-03-13 8/400 2026-03-16 12:15 by karry wen
[考研] 材料专硕306英一数二 +3 z1z2z3879 2026-03-16 3/150 2026-03-16 09:19 by Demonsssss
[考博] 东华理工大学化材专业26届硕士博士申请 +6 zlingli 2026-03-13 6/300 2026-03-15 20:00 by ryzcf
[考研] 0703化学调剂,求各位老师收留 +7 秋有木北 2026-03-14 7/350 2026-03-15 17:30 by 小物理化学
[考研] 复试调剂 +4 z1z2z3879 2026-03-14 5/250 2026-03-14 16:30 by JourneyLucky
[考研] 一志愿浙江大学0856材料与化工求调剂 +4 yansheng@211 2026-03-09 5/250 2026-03-14 02:10 by JourneyLucky
[考研] 求调剂! +4 朔朔话 2026-03-09 4/200 2026-03-14 01:38 by JourneyLucky
[考研] 一志愿郑大070303,338分,求调剂 +4 dadawaf 2026-03-10 5/250 2026-03-14 01:20 by lsw010101
[考研] 265求调剂 +9 小木虫085600 2026-03-09 12/600 2026-03-14 01:11 by JourneyLucky
[考研] 307求调剂 +7 超级伊昂大王 2026-03-10 7/350 2026-03-14 00:49 by JourneyLucky
[考研] 279求调剂 +3 Dizzy123@ 2026-03-10 3/150 2026-03-13 23:02 by JourneyLucky
[考研] 26调剂/材料科学与工程/总分295/求收留 +9 2026调剂侠 2026-03-12 9/450 2026-03-13 20:46 by 18595523086
[考研] 332求调剂 +3 Zz版 2026-03-13 3/150 2026-03-13 20:36 by 18595523086
[考研] 295求调剂 +3 小匕仔汁 2026-03-12 3/150 2026-03-13 15:17 by vgtyfty
[考研] 274求调剂 +3 S.H1 2026-03-12 3/150 2026-03-13 15:15 by JourneyLucky
[考研] 材料301分求调剂 +5 Liyouyumairs 2026-03-12 5/250 2026-03-13 14:42 by JourneyLucky
[考研] 0817化学工程与技术考研312分调剂 +3 T123 tt 2026-03-12 3/150 2026-03-13 10:49 by houyaoxu
[考研] 333求调剂 +3 152697 2026-03-12 4/200 2026-03-13 07:08 by Iveryant
[考研] 研究生招生 +3 徐海涛11 2026-03-10 7/350 2026-03-12 14:26 by 徐海涛11
[考研] 327分求调剂086 +4 西红柿?小帅 2026-03-09 7/350 2026-03-10 14:47 by ruiyingmiao
信息提示
请填处理意见