[問題] ginput的問題已回收

看板MATLAB作者 (口試要到了)時間16年前 (2009/11/17 17:30), 編輯推噓1(107)
留言8則, 3人參與, 最新討論串1/1
malab的指令中 從索引中找到ginput的相關用法 語法如下 clc clear all axis([0 10 0 10]) hold on % Initially, the list of points is empty. xy = []; n = 0; % Loop, picking up the points. disp('Left mouse button picks points.') disp('Right mouse button picks last point.') but = 1; while but == 1 [xi,yi,but] = ginput(1); plot(xi,yi,'ro') n = n+1; xy(:,n) = [xi;yi]; end % Interpolate with a spline curve and finer spacing. t = 1:n; ts = 1: 0.1: n; xys = spline(t,xy,ts); % Plot the interpolated curve. plot(xys(1,:),xys(2,:),'b-'); hold off 請問各位大大 該怎樣才能不讓右鍵的值當做最後一個值 也就是說 我按右鍵直接執行 然後輸入的最後一個data是左鍵輸入 不是右鍵輸入 謝謝各位大大的指導 -- 心機鬼屋 歡迎大家一起來耍心機 http://www.wretch.cc/blog/pazane1115 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.117.60.224

11/17 18:31, , 1F
可在plot前加判斷式
11/17 18:31, 1F

11/17 19:17, , 2F
請問一下 是什麼意思阿
11/17 19:17, 2F

11/17 20:18, , 3F
判斷 不是左鍵 => break (應該吧)
11/17 20:18, 3F

11/17 20:27, , 4F
還是TRY不出來
11/17 20:27, 4F

11/17 20:30, , 5F
在 plot(...) 前面加入一段: if but~=1, break; end
11/17 20:30, 5F

11/17 20:39, , 6F
那在問一下 為什麼我現在用這個程式 它不讓我使用啦
11/17 20:39, 6F

11/17 20:40, , 7F
出現 Error in => ginput at 13 [xi,yi,but] = ginput(1)
11/17 20:40, 7F

11/17 20:41, , 8F
我是直接照HELP裡面教的複製 下午還可以用 現在都不能用了
11/17 20:41, 8F
文章代碼(AID): #1B0crDbU (MATLAB)