Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executable 1

Status
Not open for further replies.

ahad29

Mechanical
Feb 24, 2005
46
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
 
Replies continue below

Recommended for you

If you post some code I'm sure someone might be able to help you. [surprise]
 
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

===================================================
 
try

help load



Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Here's what it looks like to me, but I'm not a programming guru:

Your function declarator
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.
 
"Do you think you used enough dynamite there, Butch?"


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
 
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"

 
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.
 
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
 
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.
 
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.
 
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
 
It's amazing what 30 seconds work on a search engine can do.


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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor