[EDIT: 20110523 16:19 CDT - merge duplicate - WDR]
I have a problem plotting something on a graph.
I have a program that runs a function, this function plots a graph. The program loops the function for different parameters. How can I make sure the output of the function is plotted on the graph next to the output from the previous loop, etc.?
This is the program code:
clear all
close all
pe_alles = 200+200*rand(10,1);
pt_alles = 80+20*rand(10,1);
ce_alles = 2547+1000*rand(10,1);
ct_alles = 450+200*rand(10,1);
for i = 1:10
pe = pe_alles(i);
pt = pt_alles(i);
ce = ce_alles(i);
ct = ct_alles(i);
Thesis_tables
end
This is the plotting end of the function:
clf reset
figure (1)
hold on
plot(y1:y2,SSB,'yo')
plot(y1:y2,SSB_ITQ,'mo')
plot(y1:y2,SSB_IQ,'ro')
plot(y1:y2,SSB_0,'go')
xlabel('Year');
ylabel('Spawning stock biomass (t)');
title('Population dynamics');
figure (2)
hold on
plot(y1:y2,TY, 'y+')
plot(y1:y2,TY_ITQ, 'm+')
plot(y1:y2,TY_IQ, 'r+')
xlabel('Year)');
ylabel('Catch (t)');
title('Fishing');
figure (5)
hold on
plot(y1:y2,P,'y')
plot(y1:y2,P_ITQ,'m')
plot(y1:y2,P_IQ,'r')
plot(y1:y2,P_ITQF,'g')
xlabel('Year');
ylabel('?');
title('Total profits')
[Material from duplicate]
Hi everyone,
I made a program that does some simple computing and comes up with 5 graphs, each with some process form the computing described on it:
clf reset
figure (1)
hold on
plot(y1:y2,SSB,'o-')
xlabel('Year');
ylabel('Spawning stock biomass (t)');
title('Population dynamics');
figure (2)
hold on
plot(y1:y2,TY, '+-')
xlabel('Year');
ylabel('Catch (t)');
title('Fishing');
figure (3)
hold on
plot(y1:y2,PE)
xlabel('Year');
ylabel('?');
title('Total profits from food herring fishery');
figure (4)
hold on
plot(y1:y2,PT)
xlabel('Year');
ylabel('?');
title('Total profits from fodder herring fishery');
figure (5)
hold on
plot(y1:y2,P)
xlabel('Year');
ylabel('?');
title('Total profits')
Than I comment the parameters used in this function and make another program, that samples hundred random values (from a range) for these parameters and than the program runs for each sample.
clear all
close all
pe_alles = 200+200*rand(100,1);
pt_alles = 80+20*rand(100,1);
ce_alles = 2547+1000*rand(100,1);
ct_alles = 450+200*rand(100,1);
for i = 1:10000
pe = pe_alles(i);
pt = pt_alles(i);
ce = ce_alles(i);
ct = ct_alles(i);
Herring_Baltic
end
It is more or less a Monte Carlo simulation. The graphs for each process with each sample value are plotted on the first four figures but I can't get the last figure to plot all graphs.
I don't know how this can be? Does anyone see the problem?
This is the code for calculating what is plotted on that last graph:
for t = 1:y2-y1+1
r = 0.05;
rho(t) = (1+r)^(t-1);
p1(t) = ((TY(t)*0.086)*pe)/rho(t)-((ce*194)*g)/rho(t);
p2(t) = ((TY(t)*0.022)*pe)/rho(t)-((ce*75)*g)/rho(t);
p3(t) = ((TY(t)*0.014)*pe)/rho(t)-((ce*54)*g)/rho(t);
p4(t) = ((TY(t)*0.0004)*pe)/rho(t)-((ce*14)*g)/rho(t);
p5(t) = ((TY(t)*0.0008)*pt)/rho(t)-((ct*62)*g)/rho(t);
p6(t) = ((TY(t)*0.00003)*pt)/rho(t)-((ct*47)*g)/rho(t);
p7(t) = ((TY(t)*0.000007)*pt)/rho(t)-((ct*33)*g)/rho(t);
p8(t) = ((TY(t)*0.0000006)*pt)/rho(t)-((ct*18)*g)/rho(t);
pl1(t) = p1(t)*4.3;
pl2(t) = p2(t)*4.7;
pl3(t) = p3(t)*4.7;
pl4(t) = p4(t)*4;
pl5(t) = p5(t)*51.3;
pl6(t) = p6(t)*51.3;
pl7(t) = p7(t)*51.3;
pl8(t) = p8(t)*50;
PE(t) = pl1(t)+pl2(t)+pl3(t)+pl4(t);
PT(t) = pl5(t)+pl6(t)+pl7(t)+pl8(t);
P(t) = PE(t)+PT(t);
end
I could post all the code if necessary.