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
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.
shiva kandpal
shiva kandpal 2022-3-8
I have attached a file which contain two column vector whose convolution I want. I need the convolution's maximum value to stay less than maximum values of these columns. How to ensure that while using "conv" command?

请先登录,再进行评论。

回答(1 个)

Shivam
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)
convResult = 9×1
0.0030 0.3675 1.0550 0.8114 1.9330 2.5314 1.2460 1.4989 1.0100
% Find maximum values of input vectors and convolution
maxVec1 = max(vector1);
maxVec2 = max(vector2);
maxVec1Vec2 = max(maxVec1, maxVec2)
maxVec1Vec2 = 1.2000
maxConvResult = max(convResult)
maxConvResult = 2.5314
% If maxConvResult is greater than maxVec1vec2, scale convResult to have
% its maximum as maxVec1Vec2
if maxConvResult > maxVec1Vec2
convResult = convResult * (maxVec1Vec2/maxConvResult);
end
disp(convResult);
0.0014 0.1742 0.5001 0.3846 0.9163 1.2000 0.5907 0.7105 0.4788
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.

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by