I always get this error even this is just a simple programe >>> Out of memory. The likely cause is an ifinite recursion within the programe. Error in plotData(line23). plotData(X,y)

5 ビュー (過去 30 日間)
Hai Luu
Hai Luu 2020 年 2 月 6 日
回答済み: Hai Luu 2020 年 2 月 8 日
function plotData(X, y)
clear ; close all; clc;
figure; % open a new figure window
fprintf('Plotting Data ...\n')
data = load('ex1data1.txt');
X = data(:, 1); y = data(:, 2);
m = length(y); % number of training examples
plotData(X, y);
fprintf('Program paused. Press enter to continue.\n');
pause;
end
  3 件のコメント
Hai Luu
Hai Luu 2020 年 2 月 6 日
oh yeah, thanks in advance
Rik
Rik 2020 年 2 月 6 日
Why do you have this in your function?
clear ; close all; clc;
clear wipes your input (using a function already makes sure you have a clean workspace), close all will close any figure your user had open and might have wanted to keep, and clc doesn't make sense yet, because you haven't written anything to the command window yet.
This is an example of cargo cult programming.

サインインしてコメントする。

回答 (1 件)

Hai Luu
Hai Luu 2020 年 2 月 8 日
I just follow to the instruction. It is an excercise in the online course. However, I think I got some misunderstanding.

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by