Filter löschen
Filter löschen

how to show variation of two variables?

1 Ansicht (letzte 30 Tage)
Vert
Vert am 22 Okt. 2014
Kommentiert: Star Strider am 22 Okt. 2014
I am trying to run the following tank model, first with synthetic observation parameters, then with several sets of combinations of the two parameters (K and Smax). Those two pieces appear to work.
After that, I am trying to calculate the error (by comparing the synth values to all the model values) and then plot a mesh grid of the error as it varies with changes to each of the variables. The figure shows only Smax varying, while K appears to stay the same. This is incorrect.
Can anyone see why/show me how to fix this?
Code below, data attached.
Thank you!!
Spill Scenario Storage where k=0.1; Smax=50
SynthK=0.1;
SynthSmax=50;
Storage = [Precipmmday(1) 0];
Baseflow = [Precipmmday(1) 0];
for k1 = 2:length(Precipmmday)
Baseflow (k1,:) = [(Storage(k1-1,2)+Precipmmday(k1-1))*SynthK];
Storage(k1,:) = [(Storage(k1-1,2)+Precipmmday(k1-1))*(1-SynthK)];
end
SynthStorage = Storage;
SynthStorage (:,1) =[];
SynthSpill=SynthStorage - SynthSmax;
SynthSpill(SynthSpill<0)=0;
SynthStorage(SynthStorage>SynthSmax)=SynthSmax;
SynthBaseflow = Baseflow;
SynthBaseflow (:,1) = [];
SynthOutflow = SynthBaseflow + SynthSpill;
Run Model (10x10)
Baseflow = zeros(10,10);
Storage = zeros(10,10);
Storage = [Precipmmday(1) 0];
Baseflow = [Precipmmday(1) 0];
Smax = linspace(10,500,10);
K = linspace(0.01,1,10);
for k3 = 1:length(Smax)
for k2 = 1:length(K)
for k1 = 2:length(Precipmmday)
Baseflow(k1,k2,k3) = [(Storage(k1-1,2)+Precipmmday(k1-1))*K(k2)];
Storage(k1,k2,k3) = [(Storage(k1-1,2)+Precipmmday(k1-1))*(1-K(k2))];
end
ModelStorage = Storage;
ModelSpill=ModelStorage - Smax(k3);
ModelSpill(ModelSpill<0)=0;
ModelStorage(ModelStorage>Smax(k3))=Smax(k3);
ModelBaseflow = Baseflow;
ModelOutflow = ModelBaseflow + ModelSpill;
end
end
Calculate Difference
SynthOutflow = repmat(SynthOutflow,[1 10 10]);
Difference = ModelOutflow - SynthOutflow;
Root Mean Square Error
rmse = sqrt((sum((Difference(1:1087,:,:)).^2))/1087);
rmse1 = reshape(rmse,10,10);
RMSE Figure
figure;
mesh(K, Smax, rmse1);
xlabel('k')
ylabel('Smax')
zlabel('err')

Akzeptierte Antwort

Star Strider
Star Strider am 22 Okt. 2014
Hello again!
I made some very slight changes in your ‘rmse’ and ‘rmse1’ calculations:
% Root Mean Square Error
rmse = sqrt(mean(Difference(1:1087,:,:).^2));
rmse1 = squeeze(rmse);
since ‘RMS’ is the root of the mean of the square (or so I was taught). If you then plot your data (you will also need to rotate it in the figure window; view([-5 15]) shows it as clearly as possible), you see that there is a very slight change in ‘err’ at the minimum of ‘Smax’ as ‘K’ goes from 0 to 0.1, but no changes with respect to ‘K’ anywhere else, at least that I can see.
So your plot is showing the changes in ‘err’ with respect to ‘K’. It’s simply difficult to see them because they’re so small.
  2 Kommentare
Vert
Vert am 22 Okt. 2014
You are right. looking again, it's clear that something more serious is wrong. The synthetic observation parameters are K=0.3 and Smax = 100 but the highest error on the figure is seen when Smax values are at 100, lowest around 20.
Any ideas?
Star Strider
Star Strider am 22 Okt. 2014
We are very far from my areas of expertise, so I don’t know how your system is supposed to work. I guess that you’re modeling a watercourse with a dam, and that ‘K’ is the fraction of the watershed precipitation that is allowed to continue downstream. That part seems straightforward to me. What I don’t understand are the lines following it, defining your ‘Model’ variables.
The practical problem is the size of your matrices. You might want to take the first 10 or so rows (your ‘Precipmmday’ dimension) of your data in your various matrices and look at them. Plotting them may give you some idea as to where the problem is in your code.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by