Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Unable to use save command with a variable
Replies: 3   Last Post: Jun 4, 2013 1:01 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Mary

Posts: 20
Registered: 12/7/10
Unable to use save command with a variable
Posted: Jun 4, 2013 11:13 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I'm trying to run a loop to extract data from an xls into different variables, and then save the list of variables as a .mat file

This is my current code:

function filter_trustdata
files = dir('*.xls')
for i= 1:numel(files)
filename = files(i).name
[data,textdata,raw]=xlsread(filename,'Data')

for i = 1:numel(textdata)
a=2
b=11
c=1
d=1
e=10

block= data(d:e,1);
round= data(d:e,2);
blue = textdata(a:b,6)
green = textdata(a:b,7)
loan_type = textdata(a:b,8)
loan_amount= data(d:e,6);
promised_diff= textdata(a:b,11);
actual_diff= textdata(a:b,12)
return_prom= textdata(a:b,13)
payouts = data(d:e,11);
actual_return= data(d:e,12);
return_desc= textdata(a:b,14)
delta=data(d:e,13);
promised=data(d:e,14);
return_greaterthan =data(d:e,15);
trustworthy =data(d:e,16);
blue_q1=data(d:e,17);
blue_q2=data(d:e,18);
blue_q3=data(d:e,19);
blue_q4=data(d:e,20);
blue_q5=data(d:e,21);
blue_q6=data(d:e,22);
blue_q7=data(d:e,23);
blue_q8=data(d:e,24);
blue_q9=data(d:e,25);
blue_q10=data(d:e,26);
blue_q11=data(d:e,27);
blue_q12=data(d:e,28);
blue_q13=data(d:e,29);
green_q1=data(d:e,30);
green_q2=data(d:e,31);
green_q3=data(d:e,32);
green_q4=data(d:e,33);
green_q5=data(d:e,34);
green_q6=data(d:e,35);
green_q7=data(d:e,36);
green_q8=data(d:e,37);
green_q9=data(d:e,38);
green_q10=data(d:e,39);
green_q11=data(d:e,40);
green_q12=data(d:e,41);
green_q13=data(d:e,42);

G_SCLPre=data(d:e,43);
B_SCLPre=data(d:e,44);
G_SCLPost=data(d:e,45);
B_SCLPost=data(d:e,46);
G_HFPre=data(d:e,47);
B_HFPre=data(d:e,48);
G_HFPost=data(d:e,49);
B_HFPost=data(d:e,50);
G_LFPre=data(d:e,51);
B_LFPre=data(d:e,52);
G_LFPost=data(d:e,53);
B_LFPost=data(d:e,54);
G_RRPre=data(d:e,55);
B_RRPre=data(d:e,56);
G_RRPost=data(d:e,57);
B_RRPost=data(d:e,58);
G_AlphaPre=data(d:e,59);
B_AlphaPre=data(d:e,60);
G_AlphaPost=data(d:e,61);
B_AlphaPost=data(d:e,62);

c=1;


savefile=strcap(textdata(2,c))

save (savefile)
a=a+1
b=b+1
c=c+1
end
end


I continue to get the error that savefile must be a string in order to save, but when I call the variable savefile it does come back as a string - savefile = 'Ds2CM###'

Any thoughts on what I might be doing wrong?



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.