creating squares of images using imagesc.
6 views (last 30 days)
Show older comments
Commented: JACINTA ONWUKA on 15 Aug 2019
The idea is to produce 2D image but is not working. I want each square to correspond to different values of rho(1x101) and beta(1x101) for JCpBest(101x101). please help me
% general parameters; will be fixed for all runs
% we will be changing P and epsilon to generate grous of graphs
% individual policy plots will be generated by a double loop
% over beta and rho
for j = 1:numel(Myrho)
for ii = 1:numel(Mybeta)
% the inner loop will be over Mycp, to find its 'best' value which
% minimmises the loss; here this value is fixed to see what happens
% create an index vector
Mycp = 0:10:100;
n = zeros(numel(Mycp),1 );
n2 = zeros(numel(Mycp),1 );
n3 = zeros(numel(Mycp),1 );
Jcp = zeros(numel(Mycp),1 );
for i = 1:numel(Mycp )
delta = 1-MycpCurrent/100 ;
tau = (1/(beta*(L+delta*p)))*log((L*(I1+delta*p))/(delta*p*(L-I1 )));
t05 =(1/(beta*(L+delta*p)))*log((L*(0.05*L+delta*p))/(delta*p*(L-0.05*L )));
I2= @(t)(L*delta*p*(exp (beta*(L+delta*p)*t)-1)) ./ (L + delta*p* exp(beta*(L+delta*p)*t ));
fun = @(t,MycpCurrent) MycpCurrent*L*exp(-r*t);
n(i) = integral(@(t)fun(t,MycpCurrent),0,100, 'ArrayValued',1);
xlabel('Secondary disease transmission rate \beta ');
Walter Roberson on 15 Aug 2019
You have invoked the form
imagesc(x, y, C)
where x and y give information about where the image is to be placed on the screen, and C is the image to be drawn.
Your Mybeta is Mybeta=0:0.003:0.3 . When used in the first argument, that would be treated the same as if you had passed in [0 0.3] in the first argument.
Your Myrho is Myrho=0:60:6000 . When used in the second argument, that would be treated the same as if you had passed in [0 6000] in the second argument.
These two parameters together mean that the center of the lower left pixel is to be placed at data units x=0 y=0, and that the center of the upper right pixel is to be placed at data units x=0.3 y=6000
Your JCpBest is JCpBest=zeros(numel(Myrho),1) which is a column vector.
You are therefore asking that the one column of data be drawn from data units x=0 to x=0.3, and y=0 to y=6000 . The result of that is going to be a vertical band, not a 2D image.
None of the three parameters you pass to imagesc() are 2D, so it is not just a matter of having accidentally used the wrong order of parameters.
More Answers (0)
Find more on Neighborhood and Block Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!