필터 지우기
필터 지우기

ginput

조회 수: 5 (최근 30일)
yahya aktas
yahya aktas 2012년 4월 20일
댓글: Yunus 2014년 12월 8일
The question is that: Read 12 arbitrary numbers from the keyboard to a vector one at a time. The numbers should all be in the range 0-20. The m-file should ask for a new number until the vector has 12 elements.The input from the keyboard must come after a request. When the vector has 12 elements it should present them as a matrix dispalyed in the command window. There should also be a plot of the numbers. Present them with ’*’ in the plot. They should be connected with a dotted line. The second part of the m-file should have a graphical reading. Mark the twelve points by a click with the mouse button in the plot ( use ginput !). Then round these twelve points towards nearest integer. Put these twelve rounded values together with the twelve original values in a matrix ( different columns). Display the matrix in the command window and put a comment there as well. Hint: Use a for-loop and ginput. Use help to find out how these work !
and my code is:
D=cell(1,12) for i=1:12, D{1,i}=input('Give me any number between 0 and 20:\n'); end celldisp(D); Z=[D{1} D{2} D{3} D{4} D{5} D{6} D{7} D{8} D{9} D{10} D{11} D{12}]; disp(Z);
x=1:1:12; plot(x,Z,'r--*','linewidth',2); axis([0 12 0 20]); xlabel('x axis') ylabel('inputs')
for i=1:12, [X,Y] = round(ginput(i)); end
it gives error like that
Error using round Too many output arguments.
Error in assignment2 (line 20) [X,Y] = round(ginput(i));
why it gives an error like that ?
Yahya Aktaş

채택된 답변

yahya aktas
yahya aktas 2012년 4월 20일
yes now it works fine but it wants from me always mouse click I only want the my twelve points by clicking..
Thank you for your answer.
  댓글 수: 1
Thomas
Thomas 2012년 4월 20일
Check my edited answer and please accept the answer if you found it helpful and solved your problem..

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

yahya aktas
yahya aktas 2012년 4월 20일
D=cell(1,12)
for i=1:12,
D{1,i}=input('Give me any number between 0 and 20:\n');
end
celldisp(D);
Z=[D{1} D{2} D{3} D{4} D{5} D{6} D{7} D{8} D{9} D{10} D{11} D{12}];
disp(Z);
x=1:1:12;
plot(x,Z,'r--*','linewidth',2);
axis([0 12 0 20]);
xlabel('x axis')
ylabel('inputs')
for i=1:12,
[X,Y] = round(ginput(i));
end

Thomas
Thomas 2012년 4월 20일
Try
for i=1:12,
[X,Y] = ginput(i);
end
X=round(X);
Y=round(Y);
EDIT for 12 inputs
remove for loop
[X,Y]=ginput(12);
X=round(X);
Y=round(Y);
  댓글 수: 2
yahya aktas
yahya aktas 2012년 4월 20일
yes know everything is okey thank you very much for your answers..
kind regards..
Yahya Aktaş
Yunus
Yunus 2014년 12월 8일
To Yahya aktaş
merhaba abi resmin belirli bölgesini seçip oradaki piksellerin konum bilgisini nasıl alabilirim ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by