[討論] 如何用surf畫出peaks

看板MATLAB作者 (來巴寶貝)時間14年前 (2011/12/20 01:48), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
因會改到peaks函式內容 因此享用別的方法來畫出圖 但遇到瓶頸 想請求幫助 因是用GUI畫面 因此讀入函試為string xx=linspace(min,max,50); yy=linspace(min,max,50); [x,y]=meshgrid(xx,yy); zz=str2double(get(handles.edit2,'string')); %zz=3*(1-x).^2.*exp(-(x.^2)-(y+1).^2)-10*(x/5-x.^3-y.^5).*exp(-x.^2-y.^2)- 1/3*exp(-(x+1).^2-y.^2) surf(x, y, zz); 但無法畫出圖 錯誤顯示 Error using ==> surf at 78 Z must be a matrix, not a scalar or vector. Error in ==> hw9>pushbutton1_Callback at 150 surf(x, y, zz); 確認過如果不讀字串近來直接將zz給其函試是畫的出來的 只要不是string 不知道是哪裡的錯誤 請求指正 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.138.33

12/20 02:32, , 1F
感覺好像還需計算讓它變50x50的矩陣 不知詳解?
12/20 02:32, 1F
文章代碼(AID): #1Exta3uW (MATLAB)
文章代碼(AID): #1Exta3uW (MATLAB)