I need to pass a function with t as independent variable as a function parameter and want to create a new function of the same through this provided the argument of another function. Here is my code.

f[t_] := t^2 + 5

Data2EWB[f[t], 0, 15, 10, "C:\Users\Jorge\Documents\desafio\aeste.txt"]


Data2EWB::usage = 
  "Data2EWB(f_, tmin, tmáx, npts, “circelet.txt”) Salva \
   arquivo com nome desejado para função de Entrada"

Data2EWB[y_, tmin_, tmax_, npts_, dir_] := 
   MatrixForm[Table[{t // N, funcaot[y, t] // N}, {t, tmin, tmax, (tmax - tmin)/npts}]]];
funcaot[y_, t_] := fc[y, t];
fc[y_, t_] := y;

I need to resolve the function that was passed as a parameter, to save data in the txt, but do not know how to do this.


This is a partial answer or maybe just an extended comment.

Your expression

Data2EWB[f[t], 0, 15, 10, "C:\Users\Jorge\Documents\desafio\aeste.txt"]

has two problems. First, f[t] should just be f. Second, at least as it appears in your question "C:\Users\Jorge\Documents\desafio\aeste.txt" will give syntax errors.

I would suggest trying

Data2EWB[f, 0, 15, 10, 
  FileNameJoin[{"C:", "Users", "Jorge", "Documents", "desafio", "aeste.txt"}]]

Or, better, assuming that C:\Users\Jorge\Documents\ is your documents directory

Data2EWB[f, 0, 15, 10, FileNameJoin[{$UserDocumentsDirectory, "desafio", "aeste.txt"}]]

I am not saying this will fix your code. But you need to deal with these very basic issues to go forward. I would further suggest you should get your code working at top-level before adding the complication of wrapping it in a package.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.