Need help in average velocity (Si-Sf)/(Ti-Tf) code. without using in built functions

조회 수: 3 (최근 30일)
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')

채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 31일
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
Diana Hopps
Diana Hopps 2016년 11월 1일
I tried to use that before but i still can't calculate the velocity from the excel columns. I just need the formula to read the two columns i will do the rest
Walter Roberson
Walter Roberson 2016년 11월 1일
num = xlsread(filename);
columnA = num(:,1);
columnB = num(:,2);

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Diana Hopps
Diana Hopps 2016년 11월 1일
i tried to use that before, but still i can't solve the average

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by