i need MATLAB code to I have yield data of 38 days , i want to expand the no of data to 151 keeping the sum same

3 visualizzazioni (ultimi 30 giorni)
[3.46, 3.53, 6.00, 5.21, 8.66, 7.87, 9.97, 8.45, 7.97, 8.24, ...
7.08, 10.00, 8.85, 8.53, 7.55, 9.97, 11.04, 7.00, 12.62, ...
11.84, 12.99, 13.70, 14.46, 11.87, 12.56, 19.07, 16.75, ...
15.56, 16.20, 15.95, 19.98, 7.83, 3.83, 10.14, 6.63, 12.93, ...
8.58, 4.02];
i need to make it 151 keep the yield same

Risposte (1)

Cris LaPierre
Cris LaPierre il 23 Mag 2023
You haven't provided any requirements, so the easiest way to do this is to just pad your vector with zeros.
old = [3.46, 3.53, 6.00, 5.21, 8.66, 7.87, 9.97, 8.45, 7.97, 8.24, ...
7.08, 10.00, 8.85, 8.53, 7.55, 9.97, 11.04, 7.00, 12.62, ...
11.84, 12.99, 13.70, 14.46, 11.87, 12.56, 19.07, 16.75, ...
15.56, 16.20, 15.95, 19.98, 7.83, 3.83, 10.14, 6.63, 12.93, ...
8.58, 4.02];
sum(old)
ans = 386.8900
new = old;
new(1,151) = 0;
size(new)
ans = 1×2
1 151
sum(new)
ans = 386.8900
  3 Commenti
PRABHAT
PRABHAT il 24 Mag 2023
% Define the original time series
time_orig = 0:34;
yield_orig = [2.83, 4.44, 3.90, 2.72, 4.44, 5.94, 4.29, 4.27, 4.29, 5.84, 6.53, 6.63, 8.64, 5.17, 9.13, 6.33, 8.62, 7.11, 5.77, 9.71, 7.08, 7.90, 6.28, 7.45, 8.23, 10.54, 9.81, 9.74, 13.40, 9.53, 8.42, 10.93, 4.92, 8.64, 5.75, 3.84, 5.22];
% Define the new time series with higher frequency
sampling_rate = 2;
total_time = time_orig(end) + 1/sampling_rate * (151 - length(yield_orig));
time_orig = linspace(0, total_time, length(yield_orig));
time_new = linspace(0, total_time, 151);
% Perform linear interpolation
yield_new2 = interp1(time_orig, yield_orig, time_new);
disp(yield_new2)
Columns 1 through 19 2.8300 3.2164 3.6028 3.9892 4.3756 4.3320 4.2024 4.0728 3.9432 3.7112 3.4280 3.1448 2.8616 2.9264 3.3392 3.7520 4.1648 4.5600 4.9200 Columns 20 through 38 5.2800 5.6400 5.8740 5.4780 5.0820 4.6860 4.2900 4.2852 4.2804 4.2756 4.2708 4.2740 4.2788 4.2836 4.2884 4.5380 4.9100 5.2820 5.6540 Columns 39 through 57 5.9228 6.0884 6.2540 6.4196 6.5380 6.5620 6.5860 6.6100 6.7104 7.1928 7.6752 8.1576 8.6400 7.8072 6.9744 6.1416 5.3088 5.9620 6.9124 Columns 58 through 76 7.8628 8.8132 8.6820 8.0100 7.3380 6.6660 6.6048 7.1544 7.7040 8.2536 8.4992 8.1368 7.7744 7.4120 7.0564 6.7348 6.4132 6.0916 5.7700 Columns 77 through 95 6.7156 7.6612 8.6068 9.5524 9.1840 8.5528 7.9216 7.2904 7.2112 7.4080 7.6048 7.8016 7.7056 7.3168 6.9280 6.5392 6.3736 6.6544 6.9352 Columns 96 through 114 7.2160 7.4812 7.6684 7.8556 8.0428 8.2300 8.7844 9.3388 9.8932 10.4476 10.3940 10.2188 10.0436 9.8684 9.7988 9.7820 9.7652 9.7484 10.1792 Columns 115 through 133 11.0576 11.9360 12.8144 13.0904 12.1616 11.2328 10.3040 9.4856 9.2192 8.9528 8.6864 8.4200 9.0224 9.6248 10.2272 10.8296 9.7280 8.2856 6.8432 Columns 134 through 151 5.4008 5.5152 6.4080 7.3008 8.1936 8.2932 7.5996 6.9060 6.2124 5.5972 5.1388 4.6804 4.2220 3.8952 4.2264 4.5576 4.8888 5.2200
Cris LaPierre
Cris LaPierre il 24 Mag 2023
Modificato: Cris LaPierre il 24 Mag 2023
What days are your yield days? What days are your growing degree days? What assumptions can be made about yield on days you do not have data?
If you want to analyze the correlation between the two, you can't just arbitrarily modify your data. It will make your results meaningless.
I'm not sure what relationship you are looking for, but I would think it might make more sense to convert your GDD array down to 38 values instead of 151. I'm not sure what values it contains, but it seems for each yield day, I could combine all the preceeding GDD into a single number. Then run the correlation on that data. That more accurately reflects the data you really have.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by