Need help in average velocity (Si-Sf)/(Ti-Tf) code. without using in built functions
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Diana Hopps
el 31 de Oct. de 2016
Comentada: Walter Roberson
el 1 de Nov. de 2016
I need help in this problem. This is the first time using A programming software and its a challenge. given a set of data on excel in two columns, time and distance, they are not sorted and have 4000 rows. The program needs to just calculate the average velocity (Si-Sf/Ti-Tf) from the excel columns and give one final answer and display it. Thank You in advance.
Here is a what i did, although it's not correct and i don't know how to proceed.
clc,clear
filename = 'LoopingData.xlsx';
[rows, columns] = size(filename);
for col = 1 : columns
theSum = 0;
for row = 1 : rows
theSum = theSum + filename(row, col);
end
% Now get the mean over all values in this column.
columnMeans(col) = theSum / rows;
end
disp (columnMeans)
columnB = xlsread(filename,'B:B')
columnA = xlsread(filename,'A:A')
0 comentarios
Respuesta aceptada
Walter Roberson
el 31 de Oct. de 2016
filename = 'LoopingData.xlsx';
creates filename as a row vector of characters.
theSum = theSum + filename(row, col);
would access specific characters in the row vector, and would never attempt to look at the content of the file.
You need to xlsread() the file and process that, such as
num = xlsread(filename);
and then iterate over the contents of num
2 comentarios
Walter Roberson
el 1 de Nov. de 2016
num = xlsread(filename);
columnA = num(:,1);
columnB = num(:,2);
Más respuestas (1)
Ver también
Categorías
Más información sobre Data Import from MATLAB 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!