Matlab questions: Read from Excel file

  • Context: MATLAB 
  • Thread starter Thread starter pp84
  • Start date Start date
  • Tags Tags
    Excel File Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 3K views
pp84
Messages
4
Reaction score
0
Hi,
Looking for a bit of cheeky help with matlab, I am stumped!

1) I have written a program that i want to cycle through different sets of data, ideally this is what i would like:
These are all xls files with columns of data

ydata = ...
xdata = ...
zdata = ...

for variable = ydata:xdata:zdata
do function to each of the variables seperatly
write function results(variable) and save data
end

Is this possible?

2) When calling a file name eg:

[FTSE] = xlsread('Normalised Smooth Data.xlsx', 'FTSE', 'A1:A300')

I want to replace 300 with a variable rather than changing many of them manually everytime i need to change that number, so i would have something like this:

numberofpoints = 300
[FTSE] = xlsread('Normalised Smooth Data.xlsx', 'FTSE', 'A1:Anumberofpoints')

Again, is this possible? I am sure it is i just don't know the key commands.

Any help would be much appretiated.

Thanks

Punit
 
Physics news on Phys.org
One way of doing this would be to use string concatenation to construct the relevant string, i.e., do something like
Code:
N = 300;
str = strcat('A1:A',int2str(N));
You can then use the str variable instead of 'A1:A300' in your original code (or you can put the strcat and everything in its argument as the argument of xlsread directly).
 
  • Like
Likes   Reactions: Wrichik Basu