Why am I getting an error 'Execution of script cosamp as a function is not supported'

30 ビュー (過去 30 日間)
Sabian Hibbs
Sabian Hibbs 2021 年 11 月 1 日
編集済み: Elghandouri Mohammed 2022 年 1 月 25 日
%% Generate signal, DCT of signal
n = 4096; % points in high resolution signal
t = linspace(0, 1, n);
x = cos(2* 97 * pi * t) + cos(2* 777 * pi * t);
xt = fft(x); % Fourier transformed signal
PSD = xt.*conj(xt)/n; % Power spectral density
% Randomly sample signal
p = 128; % num. random samples, p=n/32
perm = round(rand(p, 1) * n);
y = x(perm); % compressed measurement
% Solve compressed sensing problem
Psi = dct(eye(n, n)); % build Psi
Theta = Psi(perm, :); % Measure rows of Psi
s = cosamp(Theta,y,10,1.e-10,10); % CS via matching pursuit
xrecon = idct(s); % reconstruct full signal
  2 件のコメント
Chris
Chris 2021 年 11 月 1 日
What is cosamp? If it's a FileExchange function, are you capitalizing letters appropriately? If it's something you made, is it a function that accepts inputs and returns an output?

サインインしてコメントする。

回答 (2 件)

Elghandouri Mohammed
Elghandouri Mohammed 2022 年 1 月 25 日
Hi.
Please, have you solved this problem or not? I have the same problem, I don’t know how I can solve it.
Thank you.
  3 件のコメント
Elghandouri Mohammed
Elghandouri Mohammed 2022 年 1 月 25 日
You should verify the dimension of your matrix theta and the vector y.
May be you have also another script called cosamp.m somewhere in your Matlab path, which Matlab is attempting to run, then you should rename this script or move it.

サインインしてコメントする。


Chris
Chris 2022 年 1 月 25 日
編集済み: Chris 2022 年 1 月 25 日
Using the function provided by @Elghandouri Mohammed and the original script, the error I get is:
Error using _*_
Incorrect dimensions for matrix multiplication. ...
That can be remedied by transposing y, so that its dimensions correlate with Theta's dimensions:
s = cosamp(Theta,y',10,1.e-10,10);
If you are still getting 'Execution of script cosamp as a function is not supported'
Then there is a script called cosamp.m somewhere in your Matlab path, which Matlab is attempting to run.
type which cosamp in the Matlab Command Window to locate it, and rename it or remove it from Matlab's path.
  1 件のコメント
Elghandouri Mohammed
Elghandouri Mohammed 2022 年 1 月 25 日
The function is working good for me, maybe you should close your Matlab map and open it again.
You should also save the function cosmap.m in the folder where your script program is saved, and remove the old function named cosmap.m

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by