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 CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by