I am trying to use functions within functions. There seems to be a problem with fetching values. Can I please get help?

1 view (last 30 days)
I always get a new error when I run my code.
x = inputdlg({'Pathogen','Month (First letter capital)', 'Population Renewal', 'Death Rate'}, 'Inputs - Please enter the following information'); g = getfield(x,{1}); f = getfield(x,{2}); if strcmp('g','Salmonella') if any (strcmp(f,{'November','December','January','February','March','April'})) %if ismember (f,{'January','February'}) b = 0.01 elseif any (strcmp(f,{'May','June','July','August'})) b = 0.0001 else b = 0.001 end end
%b = str2double(x{1}); p = str2double(x(3)); l = 0.5; d = 0.9; m = str2double(x(4)); f = (b*p)*(1+(l*d)); h = m*(m+l); R = f/h;
if (R<1) answer = msgbox(['Value = ' num2str® ' therefore there is no epidemic'],'Basic Reproduction number') else answer = msgbox(['Value = ' num2str® ' therefore there is an epidemic'],'Basic Reproduction number') end
yo = [20 5 5 10]; [t x]= prmgr(p,m,yo); plot(t,x(:,1),'k','Linewidth',1.5) hold [t y] = msifunc(b,p,m,l,d,yo); plot(t,y(:,1),'-r*','Linewidth',1.5,'MarkerSize',5) title('Susceptible Population') legend('Disease free state','Test state')
if strcmp('g','Shigella') if any (strcmp(f,{'November','December','January','February','March'})) %if ismember (f,{'January','February'}) b = 0.01 elseif any (strcmp(f,{'May','April','October'})) b = 0.001 else b = 0.00001 end
end %b = str2double(x{1}); p = str2double(x(3)); n = 0.14; m = str2double(x(4)); f = b*p; h = m*(m+n); R = f/h;
if (R<1) answer = msgbox(['Value = ' num2str® ' therefore there is no epidemic'],'Basic Reproduction number') else answer = msgbox(['Value = ' num2str® ' therefore there is an epidemic'],'Basic Reproduction number') end
yo = [20 5 10]; [t u] = ugr(p,m,yo); plot(t,u(:,1),'k','Linewidth',1.5) hold [t v] = shigfunc(b,p,m,yo) plot(t,v(:,1),'-r*','Linewidth',1.5,'MarkerSize',5) title('Susceptible Population') legend('Disease free state','Test state')
if strcmp('g','Rotavirus') if any (strcmp(f,{'May','June','July','August'})) b = 0.1 elseif any (strcmp(f,{'October','March'})) b = 0.001 else b = 0.01 end end
%b = str2double(x{1}); p = str2double(x(3)); l = 0.5; d = 0.9; q = 0.4 m = str2double(x(4)); f = (b*p*q); h = m*(m+l); R = f/h;
if (R<1) answer = msgbox(['Value = ' num2str® ' therefore there is no epidemic'],'Basic Reproduction number') else answer = msgbox(['Value = ' num2str® ' therefore there is an epidemic'],'Basic Reproduction number') end
yo = [20 5 5 10]; [t w]= rota(p,m,yo); plot(t,w(:,1),'k','Linewidth',1.5) hold [t z] = rotfunc(b,p,m,l,d,yo); plot(t,z(:,1),'-r*','Linewidth',1.5,'MarkerSize',5) title('Susceptible Population') legend('Disease free state','Test state')
  2 Comments
Adam
Adam on 16 Feb 2015
Please format your code in a '{} Code' block and include all error information that you get, especially including which line is causing the error. Just telling us you get an error is not very helpful if you want people to help you.
Stephen23
Stephen23 on 16 Feb 2015
This is unreadable code. Please edit your question and format the code using the {} Code button above the textbox.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!