I’m stuck in one case related to matlab.
I create a file through script by using these commands:
delete output
delete f.m
clc;
% This is a Cell Array!
prompt={'Enter Function f(x) Here :'};...
% Name of the Dialog Box
name='Trapezoidal Rule Input Screen';...
numlines=1; % Number of lines visible for User Input
% Default Answer
defaultanswer={'1 + exp(-x).*sin(4*x)'};...
% Creating the Dialog box where the User Input is stored into a Cell Array
answer=inputdlg(prompt,name,numlines,defaultanswer);...
global y1
y1=answer{1};...
diary f.m;
disp('function y = f(x)');...
%disp('y = '),disp(y),disp(';');...
%disp('y = ((1+(x^2))^-1);');...
fprintf('y=%s;\n',y1);
diary off;
f(0);
when the click on RUN CHECK button then f.m file had been created because it is part of script and generate the following code in f.m file
function y = f(x)
%disp('y = '),disp(y),disp(';');...
%disp('y = ((1+(x^2))^-1);');...
fprintf('y=%s;\n',y1);
y=1 + exp(-x).*sin(4*x);
diary off;
but it stop and highlight error that y1 is apparently use before it is define.
fprintf('y=%s;\n',y1);
so if any 1 have some solution regarding this problem please help me out.
I would not abuse the diary command for this.
Why not just: