I want to plot a hydropgraph for an analytical solution of discharge. My solution contain convolution. How can I use inbuilt conv of matlab to plot this?
3 次查看(过去 30 天)
显示 更早的评论
I tried the command "conv(vector 1, vector 2)" but I am not getting the expected result. Is there some other technique to plot hydrographs in matlab?
2 个评论
Steven Lord
2022-2-28
What are the contents of the two vectors, what result do you receive, and what result did you expect? With that information we may be able to offer some suggestions for how to reconcile the difference between what you received and what you expected.
回答(1 个)
Shivam
2024-1-4
Hi Shiva,
From the information you have shared, I understand that you are performing the convolution of two vectors, and you want the convolution maximum value to be less than the maximum values of the 2 column vectors.
To achieve this, you can scale the convolution output. This will ensure that its maximum value is less than or equal to the peaks of the original vectors.
You can refer to the following code for two assumed vectors, as the CSV file you mentioned contains only one column vector:
vector1 = [0.3; 0.75; 0.2; 0.89; 1];
vector2 = [0.01; 1.2; 0.51; 0.6; 1.01];
% Perform the convolution
convResult = conv(vector1, vector2)
% Find maximum values of input vectors and convolution
maxVec1 = max(vector1);
maxVec2 = max(vector2);
maxVec1Vec2 = max(maxVec1, maxVec2)
maxConvResult = max(convResult)
% If maxConvResult is greater than maxVec1vec2, scale convResult to have
% its maximum as maxVec1Vec2
if maxConvResult > maxVec1Vec2
convResult = convResult * (maxVec1Vec2/maxConvResult);
end
disp(convResult);
Also, it's important to note that when you adjust the scale of the convolution output, the relative magnitude among the values within the convResult will remain same.
In addition, if you want the maximum of the convolution to be strictly less than the maximum values of the individual column vectors, the convolution vector can be scaled by a factor slightly less than maxVec1Vec2/maxConvResult.
Please refer to the following documentation to know more about the 'conv' function: https://www.mathworks.com/help/releases/R2023b/matlab/ref/conv.html
I hope it helps.
Thanks.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!