how to deconvolute a array ?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
hy guys
i would like to deconvolute a matrix
code:
clear all
clc
a=rand(10,3);
b=rand10,3); %b=conv2(a,c)
%suppose that b is already the convolution of the array "a" with an array "c"
% I would like to deconvulte " b " to re-obtain "a" and "c".
% any idea how to do so?
% thanks you in advance
採用された回答
Chris Turnes
2022 年 2 月 9 日
Deconvolution is equivalent to polynomial division. You can get the polynomial division and its remainder with the deconv function.
rng('default');
% Take two vectors.
a = randn(7,1);
c = randn(10,1);
% Compute their convolution.
b = conv(a, c);
% "Recover" the first by deconvolving c from b:
[ahat,r] = deconv(b, c);
% Check the residual and the remainder polynomial
norm(a-ahat)
ans = 8.1907e-11
r'
ans = 1×16
1.0e+-9 *
0 0 0 0 0 0 0 0.2664 0.2397 -0.1352 0.2409 0.0603 -0.0114 0.0599 -0.0156 -0.0101
However, it's important to note that this is not a least-squares solution to the deconvolution, and if b isn't really the result convolving something with c, you may not get an answer that's particularly close to the least squares result. To get the least squares result, you would construct the Toeplitz system corresponding to the convolution and solve it:
% Add some "noise" to c:
bhat = conv(a, c + 1e-3*randn(size(c)));
% Solve with deconv:
ahat_deconv = deconv(bhat, c);
% Compare convolving the result with c against the vector we started with:
norm(bhat - conv(ahat_deconv, c))
ans = 6.0224e+03
% Solve with least-squares:
T = convmtx(c, length(a));
ahat_ls = T \ bhat;
% Compare convolving the least-squares result with c against the vector we
% started with:
norm(bhat - conv(ahat_ls, c))
ans = 0.0044
There are efficient algorithms to solve the Toeplitz system, though there are not any functions directly in MATLAB to do so.
8 件のコメント
Rabih Sokhen
2022 年 2 月 11 日
thank you
Rabih Sokhen
2022 年 2 月 11 日
is it possible to do the same in 2D , with marix "a","b" and "c"?
Chris Turnes
2022 年 2 月 11 日
編集済み: Chris Turnes
2022 年 2 月 11 日
Yes:
% Generate source data.
a = randn(5, 7);
c = randn(9, 11);
% Convolve.
b = conv2(a,c);
% De-convolve via least squares.
% convmtx2 returns a sparse matrix, so cast
% to full.
ahat = full(convmtx2(c, size(a)) \ b(:));
% Reshape to a 2-D array.
ahat = reshape(ahat, size(a));
% Check the result.
norm(a-ahat, 'fro')
ans = 2.0547e-15
Rabih Sokhen
2022 年 2 月 11 日
Wow, that's great.
Is it possible to do the same, but this time we consider that we already have the matrix "c" and "a" and c=conv2 (a, b) and we want to find " b "?Is there a way to find "b" with the minimum error possible?
thank you in advance
Chris Turnes
2022 年 2 月 11 日
編集済み: Chris Turnes
2022 年 2 月 11 日
Yes, I think this is just a labeling question. If you take my example and replace "b" with "c", "a" with "b", and "c" with "a" then I think it gives exactly what you're asking.
For what it's worth, I am just building the matrix and solving the system with \ because it's convenient for illustration; in practice you may want to consider an iterative method instead that doesn't require you to explicitly build the matrix, as the convolution matrix can become quite large if the inputs are large.
There are also fast methods for solving these 2-D systems, but again, there are no functions directly in MATLAB to my knowledge that do this.
Rabih Sokhen
2022 年 2 月 11 日
okay deal
thank you Chris
Rabih Sokhen
2022 年 2 月 11 日
clear all
clc
a = randn(5, 7);
c = randn(13,17);
b= full(convmtx2(a, size(a)) \ c(:));
b= reshape(b, size(c)-size(a)+1);
%i tried the following code but i got a error, can you plz help me fix it?
Chris Turnes
2022 年 2 月 11 日
Your error here is that you're not specifying the right size for the convolution matrix. The size argument is the size of the thing you are convolving with a -- so in this case, the size of b. You've alredy determined this later, so you just need to pass it into the function:
a = randn(5, 7);
c = randn(13,17);
szB = size(c) - size(a) + 1;
b= full(convmtx2(a, szB) \ c(:));
b= reshape(b, szB);
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Linear Algebra についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
