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?
4 ビュー (過去 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!