Plotting user inputs in a 2D plot

조회 수: 28 (최근 30일)
Alexander Tollinger
Alexander Tollinger 2020년 3월 26일
답변: KSSV 2020년 3월 26일
Hey guys,
I'd need some help from you regarding the following problem. I want the user to enter numbers in the command window ( input(prompt) ) and plot the numbers. (Inputs should be visualized as points). For example: first input should be on x-coordinate 1 , second user input should be at x-coordinate 2 and so on. The y-coordinates of each point should be represented by the number that the user enters in the command window.
clc;
clear all;
close all;
x = 0:1:10;
numberOfInputs = 0;
prompt = 'Enter any number that you like:';
%{ I only want the user to enter a maximum of 10 numbers. %}
while numberOfInputs <=10
if input(prompt) == true
enteredValue = input(prompt);
numberOfInputs = numberOfInputs + 1;
%plot()
end
end
Would really appreciate it if somebody could help me with this.
Best regards and stay safe,
Alex

채택된 답변

KSSV
KSSV 2020년 3월 26일
prompt = 'Enter any number that you like:';
%{ I only want the user to enter a maximum of 10 numbers. %}
N = 10 ;
figure
hold on
for i = 1:N
enteredValue = input(prompt);
plot(i,enteredValue,'s')
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by