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

36 views (last 30 days)
Sabian Hibbs
Sabian Hibbs on 1 Nov 2021
Edited: Elghandouri Mohammed on 25 Jan 2022
%% 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 Comments
Chris
Chris on 1 Nov 2021
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?

Sign in to comment.

Answers (2)

Elghandouri Mohammed
Elghandouri Mohammed on 25 Jan 2022
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 Comments
Elghandouri Mohammed
Elghandouri Mohammed on 25 Jan 2022
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.

Sign in to comment.


Chris
Chris on 25 Jan 2022
Edited: Chris on 25 Jan 2022
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 Comment
Elghandouri Mohammed
Elghandouri Mohammed on 25 Jan 2022
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

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by