I want to use an input dialog box for inputs in one m-file and use these inputs in another function…
Here is the first code:
x = inputdlg({'Rate', 'Population renewal', 'Death rate'}, 'Inputs')b = str2double(x{1});p = str2double(x{2});l = 0.5;d = 0.9;m = str2double(x{3});v = (b*p)*(1+(l*d)); c = m*(m+l);R = /c;if (R<1) answer = msgbox(['Value = ' num2str(R) ' therefore there is no epidemic'],'Basic Reproduction number')else answer = msgbox(['Value = ' num2str(R) ' therefore there is an epidemic'],'Basic Reproduction number')end---------------------------------------------------------------------------------------------
I want to use the same inputs in another function and I am using the following code:
function msir = msirtry(t,y)load('salRo.m','l','p','b','m','d');d = 0.9;c = 0.14;a = 0.25;r = 0.05;msir(1) = p - m*y(1)- b*y(1)*y(2)*(1+(l*d)) + a*y(4);msir(2) = b*y(1)*y(2)*(1+(l*d)) - (m + l)*y(2);msir(3) = l*d*y(2) - (m + r)*y(3);msir(4) = l*c*y(2) + r*y(3) - (m + a)*y(4);msir = msir(:);--------------------------------------------
and i am running this function using
yo = [20 5 5 10]; [t y] = ode45(@msirtry,[0 5],yo); plot(t,y(:,1),t,y(:,2),t,y(:,3),t,y(:,4),'Linewidth',2.5)legend('Susceptible','Infected Symptomatic','Infected Asymptomatic','Recovered')--------------------------------------------------------------
I get the error – Number of columns on line 1 of ASCII file
C:\Users\Krishnaa\Documents\MATLAB\salRo.mmust be the same as previous lines.
if i manually put in the inputs instead of loading it, the codes work but I need to work all this out together… pls help…
Best Answer