Plot produces blank figure.
58 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
David Rainbeau
le 9 Mai 2016
Commenté : Nicholas Jackson
le 14 Août 2018
Taking a course and running through a very simple example, but my Figure opens with just a blank black image. The data looks like it is loaded properly into X and y. Any guidance would be great.
clear ; close all; clc
fprintf('Plotting Data ...\n')
data = load('ex1data1.txt');
X = data(:, 1); y = data(:, 2); m = length(y);
% Plot Data
plotData(X, y);
fprintf('Program paused. Press enter to continue.\n');
pause;
% Function %
function plotData(x, y)
figure;
plot(x, y, 'rx', 'MarkerSize', 10);
ylabel('Profit in $10,000s');
xlabel('Population of City in 10,000s');
end
2 commentaires
Adam
le 9 Mai 2016
Have you stepped through with the debugger to look at x and y?
It's difficult to suggest anything as we don't have your data and nothing jumps out from the code to me as being blatantly wrong.
Also have you tried it without the 'pause' instruction? It may just be a case of the plot not being drawn yet because it is paused.
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Performance dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!