The learning problem in MATLab, how do I code it?

1 回表示 (過去 30 日間)
Jon Camilleri
Jon Camilleri 2015 年 11 月 25 日
コメント済み: Walter Roberson 2015 年 11 月 25 日
I am trying to convert information from a CSV file into data that I can plot to a graph but I have some data conversion problems.
Using a for loop so far has proven unsuccessful unfortunately.
function [average] = classifyIris(file)
% Detailed explanation goes here
load(file);
average = sum(file)/numel(file);
for i = 1:size(iris_data)
double tmp1 = str2double(iris_data{i,i};
end;
end
I am working towards coding a machine learning classification algorithm.
Further reading
  1. http://www.mathworks.com/help/matlab/ref/linspace.html
  2. http://www.mathworks.com/matlabcentral/newsreader/view_thread/147624

採用された回答

Walter Roberson
Walter Roberson 2015 年 11 月 25 日
You are passing a string in to the routine that is the name of a file that you load. You then calculate the average of the string, not of the content of the file.
You should use csvread() or xlsread() or you should use load() with an output argument such as
data = load(file);
then you can calculate mean(data(:)) and so on.
You appear to have a variable named iris_data defined in a different scope. Or possibly your load() is not of a csv file and instead is of a .mat file and you are "poofing" variables into existence. Use the output form of load() instead of doing that.
  2 件のコメント
Jon Camilleri
Jon Camilleri 2015 年 11 月 25 日
How would I code this therefore?
Walter Roberson
Walter Roberson 2015 年 11 月 25 日
Where is the content for iris_data coming from? Why are you doing any calculation with it, considering that you are calculating your only return variable, "average", before that line? Does "file" refer to a csv file or to a .mat file? If it is a csv file then how many items are there per line? Do you want the average by row or by column or the overall average? If it is a .mat file then what are the names of the variables stored in the file?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by