Marking a specific point on a PDF graph

4 visualizaciones (últimos 30 días)
J Morgan Alsbrook
J Morgan Alsbrook el 11 de Dic. de 2019
Editada: Ridwan Alam el 11 de Dic. de 2019
How can I mark a point with an (x,y) coordinate on this plot. I have attached my code. A user enters an academic class 2A 2B 3A 3B,, etc and then a gpa. I want it to find the entered gpa and mark a point on it on the graph.
Here is my code:
%This program tells the probability of getting a GPA given all of the
%department's students and their gpa's
clear;
close all;
clc;
% Asks what your academic class and gpa are and inputs into matrix
prompt = {'Academic Class','GPA'};
dlgtitle = 'GPA Probability Calculator';
dims = [1 35];
definput = {'Exp. 1B','Exp. 4.0'};
answer = inputdlg(prompt,dlgtitle,dims,definput)
%This imports the GPA & Academic class data from fall 2016 and puts it in
%an array
grades = readtable('2016grades.xlsx');
%Read table and find corresponding GPAs to academic class
celldisp(answer)
mask = strcmp(grades{:,1}, answer{1});
retrieved_class = grades{mask, 2};
%Plot a PDF
[p,x] = hist(retrieved_class); plot(x,p/sum(p)); %PDF
Here's is my output if I enter 3B for my academic class.

Respuestas (1)

Ridwan Alam
Ridwan Alam el 11 de Dic. de 2019
Editada: Ridwan Alam el 11 de Dic. de 2019
gradeIn = str2num(answer{2});
[p,x] = hist(retrieved_class);
p = p/sum(p);
figure;plot(x,p)
hold on; plot(x(x==gradeIn),p(x==gradeIn),'ro')

Categorías

Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by