seeking help with xlswrite function
1 view (last 30 days)
I'm trying to loop through this code 3 times and save the variable states to the excel file. I want to name the excel files 1.xls, 2.xls and 3.xls.
Could anybody tell me what I am doing wrong with the xlswrite as it is not working. Thank you.
transC = [zeros(size(T,1),1), cumsum(T,2)]; %cumulative sum of rows, we will use this to decide on the next step.
n = 10000;
states = zeros(1,n); %storage of states
states(1) = 32; %start at state 1 (or whatever)
for ii = 2:n
%Generate a random number and figure out where it falls in the cumulative sum of that state's trasition matrix row
[~,states(ii)] = histc(rand,transC(states(ii-1),:));
Image Analyst on 6 Jan 2013
You need to construct the filename properly. Replace this:
baseFileName = sprintf('%d.xls', j);
fullExcelFileName = fullfile(yourFolder, baseFileName); % yourFolder can be pwd if you want.
xlswrite(fullExcelFileName ,[states],'Sheet1', 'A2');