×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Executable

Executable

Executable

(OP)
I have a function that takes 4 input files which are in .txt format. I created an executable with the function and when I run it in dos prompt. I get an error
"ERROR can't open file ALoad.txt."
ALoad is one of my input files in the function. I deleted the file extensions and tried again but I get the same error. However when I run the function from matlab prompt I get good result. Could someone please tell me how I can resolve this problem. Thanks.
 
ahad

RE: Executable

If you post some code I'm sure someone might be able to help you.

RE: Executable

(OP)
Here is my code
=====================================================

function [g] = afitfun(Aload,Delunz,Int,sc,FSLoad)
% Input files
load Aload.txt;
load Delunz.txt;
load Int.txt;
load sc.txt;
load FSLoad.txt;

for i=1:6
    c(:,i)=Delunz(:,i)*sc(1,i);
end
c;

d=zeros(729,6); %
for m=1:100
e=zeros(729,6);
e=c-d;
f=zeros(729,6);
for i=1:9:729
    for j=1:9
    f(i+j-1,:)=e(i+j-1,:)-e(i,:);
end
end
f;
sizef=size(f);
save testf f -ascii -tabs
save teste e -ascii -tabs

p=1;
for i=1:6
for j=1:6
h(:,p)=e(:,i).*e(:,j);
p=p+1;
end
end
del=[7,13,14,19,20,21,25,26,27,28,31,32,33,34,35];
l=size(h);
h(:,del(1,:))=[];
h;

hi=[e h];

g=f-Aload;
g=100*g;

for i=1:6
g(:,i)=g(:,i)/FSLoad(1,i);

d=hi*Int;

end
save Error g -ascii -tabs

end

===================================================

RE: Executable

try

help load

Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: Executable

Here's what it looks like to me, but I'm not a programming guru:

Your function declarator

Quote:

function [g] = afitfun(Aload,Delunz,Int,sc,FSLoad)
tells me that when you call the function, you are passing it the arguments in parentheses, yet the first thing you do in the function is try to load them with an incorrect load command syntax. Either you have the arguments loaded before you call the function to pass them to it, or you really don't need to pass it any arguments if you are going to load the files within the function.

xnuke
"Do you think you used enough dynamite there, Butch?"
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: Executable

"Do you think you used enough dynamite there, Butch?"

http://www.hackstadt.com/features/whale/

follow the links to the video and judge yourself !!! ; )

yes try:

help load
load -ascii filename

the ascii statement forces to see the file as ascii txt

RE: Executable

(OP)
The function will not work without the load statements like in the code above. Unless I say
>> load Aload.txt
and so on for each file at the matlab prompt.

I think the function is unable to load the files using the input arguments alone in the function and hence DOS gives an error:
"Input argument 'Delunz' is undefned"

RE: Executable

try

help load

the syntax you are trying to use is not even mentioned.

Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: Executable

(OP)
Greglocock,
You mean the syntax i used in the script or at the DOS prompt? The syntax I used is the same in both places but you are saying that it is not proper to use it either way right?
ahad

RE: Executable

Your pathname is correctly set in the live matlab session, but not in the dos prompt.

Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: Executable

(OP)
I am not too familiar with matlab but I had set my path on the environment varibles.
PATH: existingpath;C:\matlabr12\bin\win32

this is what i had set it to earlier. But i also tried
PATH: existingpath;C:\matlabr12\D1\D2

D1 D2 being the location where my input files and script are located. Alas DOS continunes to give me the same error.

RE: Executable

(OP)
I have tried a lot of options but somehow DOS doesnot seem to load the files. I was wondering if someone could send me a 3-4 line code that takes two matrix files A , B and adds them and be executable from DOS. I would greatly appreciate any help. Thanks.

ahad

RE: Executable

It's amazing what 30 seconds work on a search engine can do.

http://www.mathworks.com/support/tech-notes/1600/1620.html

Quote:


There is currently no support for loading or saving ASCII files in stand-alone code with the LOAD and SAVE commands.

WORKAROUND:

You can work around this in one of two ways. First, you can load and save to a MAT-file using the LOAD and SAVE commands. Otherwise, you will have to use low-level file I/O routines to read in a matrix from a file. For example,

fid = fopen(filename,'r');
a = fscanf(fid,'%f');
a = a';% FSCANF reads in data transposed.
fclose(fid);

M

--
Dr Michael F Platten

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources