How to plot a number of points whose coordinates are given as Input by the user in a GUI Table?
조회 수: 1 (최근 30일)
이전 댓글 표시
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166000/image.png)
As an user, I would like to keep entering different x,y and z values in the consecutive rows and the points should be plotted in the graphic handle. Thanks in advance for your help. Cheers.
댓글 수: 0
채택된 답변
Michael Haderlein
2014년 7월 22일
I think that's what you need: function test2
figure, h=uitable('data',rand(4,3),'columneditable',true(1,3),'cellEditCallback',@drawtablevalues);
figure, ha=axes;
hp=plot3(0,0,nan);
function drawtablevalues(src,evt)
data=get(src,'data');
set(hp,'xdata',data(:,1),'ydata',data(:,2),'zdata',data(:,3))
end
end
Best regards, Michael
댓글 수: 0
추가 답변 (1개)
Joseph Cheng
2014년 7월 22일
You'll have to set the parameter for the uitable to be able to be editable. http://www.mathworks.com/help/matlab/ref/uitableproperties.html the link should give you the details about that. Then in the callback/function that you're going to get the table values you need to use the get() function like Table_DATA = get(handles.uitable1,'Value') in GUIDE or equivalent if uitable programmed in an mfile.
댓글 수: 2
Joseph Cheng
2014년 7월 22일
Oh and the data coming into the Table_Data and what Michael has above will be as a cell. So i am not sure you can just do a direct plot. you may need to use cell2mat to convert it from a Cell array
Michael Haderlein
2014년 7월 22일
I don't know if the behavior has changed with a new Matlab release (it actually shouldn't for backwards compatibility), but I find data to be an array of doubles. No problem plotting that. The little piece of code above is working (at least on my machine).
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!