Question

I am new to Mathematica and want to ask perhaps a very simple question :-).

I need to read data from an input file and then process it. Due to its repeated use in my code, I make a module. An Example is given below.

MySubr[b_, e_, d_] := Module[{a, c},      
f = OpenRead["Input File.dat"];
A = Read[f, Number]; 
T = Read[f, Number]; 
WL = Read[f, Number];
RO = Read[f, Number];
a = b*RO;
c = d*A+e*T-WL;
Return[{a, c}];
]

When I call this module;

{a,c}=MySubr[2,3,4]

I get the following error; Set::shape: Lists {a,c} and MySubr[{2,3,4}] are not the same shape.

I am not sure what the error is and how can I solve this problem. All of you are requested to suggest something useful and simple.

Thanks

No correct solution

OTHER TIPS

It will help you debug your code if you run this and see where it breaks :-

{b, e, d} = {2, 3, 4};
f = OpenRead["Input File.dat"];
A = Read[f, Number];
T = Read[f, Number];
WL = Read[f, Number];
RO = Read[f, Number];
a = b*RO
c = d*A + e*T - WL
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top