如何在OSX 10.6.8上使用Octave打开.m文件

3

这个文件名为ex1.m,我用Octave打开它,但是它没有任何反应。前几行代码如下:

%% Machine Learning Online Class - Exercise 1: Linear Regression

%  Instructions
%  ------------
% 
%  This file contains code that helps you get started on the
%  linear exercise. You will need to complete the following functions 
%  in this exericse:
%
%     warmUpExercise.m
%     plotData.m
%     gradientDescent.m
%     computeCost.m
%     gradientDescentMulti.m
%     computeCostMulti.m
%     featureNormalize.m
%     normalEqn.m
%
%  For this exercise, you will not need to change any code in this file,
%  or any other files other than those mentioned above.
%
% x refers to the population size in 10,000s
% y refers to the profit in $10,000s
%

%% Initialization
clear ; close all; clc

%% ==================== Part 1: Basic Function ====================
% Complete warmUpExercise.m 
fprintf('Running warmUpExercise ... \n');
fprintf('5x5 Identity Matrix: \n');
warmUpExercise()

fprintf('Program paused. Press enter to continue.\n');
pause;

等等,还有更多文件,我不确定如何运行这个程序...


阅读Octave手册并向您的教授提问。不知道如何处理所得到的脚本文件意味着您需要了解更多关于Octave和脚本的知识,而不仅仅是如何运行它。 - carandraug
我很想帮忙,但这只是一门免费的在线课程,我无法接触到老师。 - Nathvi
1个回答

2
这似乎是来自www.coursera.org的Andrew Ng在线机器学习课程的一部分。在尝试跟随教程后,您可能会更容易在课堂网站的论坛中提出这些问题。
首先,您需要将所有相关文件放在目录中。然后完成任务。在完成代码部分之前,大多数任务都不会起作用。
这个文件包含的代码可以帮助你开始线性练习。您需要在此练习中完成以下函数:
 warmUpExercise.m
 plotData.m
 gradientDescent.m
 computeCost.m
 gradientDescentMulti.m
 computeCostMulti.m
 featureNormalize.m
 normalEqn.m

完成后,在Mac终端中打开并cd到ex1.m所在的目录。你可以通过启动octave并输入文件名不带.m扩展名来运行程序。输入ex1即可运行。另外,如果您不想在程序运行结束后停留在octave shell中,您也可以从终端输入octave -q ex1.m来运行程序。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接