Since I'm new to Mathematica I want to have a Notebook which takes inputs from user and returns average of the inputs entered and plots it on x-y coordinate. How can I do this?
Asked
Active
Viewed 1,487 times
2 Answers
4
This might be an example:
x = Input["Insert x coordinates (put them between {} brackets)",{}];
y = Input["Insert y coordinates (put them between {} brackets)",{}];
Mean[x]
Mean[y]
ListPlot[Transpose[{x, y}]]
VLC
- 9,818
- 1
- 31
- 60
-
Also check out
tutorial/RequestingInputandtutorial/TextualInputAndOutputOverviewin the Documentation Center (You can access it from the help menu, and I highly recommend the broadcasts on http://www.wolfram.com/broadcast/video.php?channel=86 to get you comfortable with mathematica) – ssch Nov 13 '12 at 16:41 -
Thanks. I will try it out. Actually i never mention my real problem but if any problem occur i will revert to stackexchange.com. Also can you tell me the best tutuorial for starter as i have to solve a simple problem(complex for starter) and submit before Thursday. – Soum Nov 13 '12 at 17:30
-
@Soum You could start from here. The Documentation is also a good place to start, for instance, for plotting. And, this collection of resources is also useful. – VLC Nov 13 '12 at 17:46
1
The question says "take input from the user", but this suggest a paradigm more suitable to another programming language. If what you $really$ want is to give the user a way to enter the data and then obtain the required plot, it's more straightforward to just define a function:
meanPlot[x_List, y_List] :=
Module[{xbar = Mean[x], ybar = Mean[y]},
Print[{xbar, ybar}];
ListPlot[Transpose[{x, y}],
Epilog -> {PointSize[Large], Red, Point[{xbar, ybar}]}]
]
And then use this so:
meanPlot[{5, 2, 9, 4}, {2, -1, 8, 2}]
The definition of meanPlot does minimal argument-checking (just that each argument is a list). And there are neater ways to combine the printout of the two means with the plot, e.g., use a Column construct or label the point of means with its coordinates.
murray
- 11,888
- 2
- 26
- 50
2)
– ssch Nov 13 '12 at 16:50Read the FAQs! 3) When you see good Q&A, vote them up byclicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem,by clicking the checkmark sign