The learning problem in MATLab, how do I code it?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Jon Camilleri
el 25 de Nov. de 2015
Comentada: Walter Roberson
el 25 de Nov. de 2015
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
0 comentarios
Respuesta aceptada
Walter Roberson
el 25 de Nov. de 2015
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 comentarios
Walter Roberson
el 25 de Nov. de 2015
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?
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!