i have a input problem.Cannot call INPUT from EVALC. in my code
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hello this message appear when i try tu publish my program Error using input * Cannot call INPUT from EVALC. Error in hw1 (line 4) year= input('Enter the year (yyyy)\n:'); *
my code is the following:
year= input('Enter the year (yyyy)\n:');
month=input('Enter the month: ');
day=input('Enter the day: ');
fprintf('\nYou entered %3.0f/%2.0f/%4.0f',month,day,year)
d=day;
m=month-2;
if m<=0
m=m+12;
year=year-1;
endy=mod(year,100); % year's number in the century
c=(year-y)/100; % number of centuries
%formula input
%weekday= mod((d+((1/5)*(13*m-1))+y+(y/4)+(c/4)-2*c+777),7);
%week={'Sunday' 'Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday'...'Saturday'};
%fprintf('\n\nYour weekday is: %s\n', week{weekday+1}); % result
%Subscript indices must either be real positive integers or logicals.
weekday= mod((d+fix((1/5)*(13*m-1))+y+fix(y/4)+fix(c/4)-2*c+777),7);
week={'Sunday' 'Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday'...
'Saturday'};
fprintf('\n\nYour weekday is: %s\n', week{weekday+1}); % result
can anyone help me?
0 comentarios
Respuestas (2)
Geoff Hayes
el 4 de Oct. de 2014
Alejandro - I copied your file and opened it in the MATLAB editor. On the Publish tab, I pressed the Publish button and observed the same error as you. The same error occurs if you run the following in the Command Window
publish('myScript.m')
This is because the default setting for the publish functionality is to evaluate the code. If you wish to disable this setting, in the editor on the Publish tab, press the down arrow on the Publish button and select Edit Publishing Options. In the Code Settings section change the Evaluate Code from true to false, and press Publish. The resulting HTML (or whatever you have selected as output) should no longer display this error.
If publishing from the command line, just disable the evaluation of your script/program as
publish('myScript.m','evalCode',false)
4 comentarios
lal popat
el 28 de Ag. de 2018
This is just avoiding execution of the code. What if I want to run the same using some temp inputs? Like executing the script with input of year, month etc
Steven Lord
el 28 de Ag. de 2018
Separate the interface and the computation pieces.
- Write a script file that uses input to prompt the user for values for the parameters. This is the interface piece.
- Write a function file that accepts the parameters as input arguments. This is the computational piece.
When you want to perform the computations interactively call the script and have it call the function directly, specifying the values the script received from the user as the inputs to the function.
When you want to perform the computations non-interactively (such as when you want to publish your results) just call the computational function directly and specify the input arguments in that function call.
Gabriela
el 15 de Jun. de 2023
clc
clear
disp('This program will calculate the time in which the crime was committed')
To=input('Enter the temperature upon arrival.To= '); %temperature in Farenheit
Ts=input('Enter the temperature of the room.Ts= '); %temperature in Farenheit
T=input('Enter the temperature after one hour after the scene.T= '); %temperature in Farenheit
%t= 1 unit in hours
k=-log((T-Ts)./(To-Ts));
NT=input('Enter the normal temperature of the body.NT= '); %temperature in Farenheit
t=-(1/k)*log((T-Ts)./(NT-Ts)); %time in hours fprintf('\nThe time at which the crime was commited was %.2f hours before they arrived\n',t) This program will calculate the time in which the crime was committed
Gave me teh same error. But I do what it says in the instructions and it keep giving me the same error.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!