Undefined function or variable 't'.
5 vues (au cours des 30 derniers jours)
I am trying on solving optimization problem but i gt the error
'Undefined function or variable 't'.
abs_H=abs(ifft(H));% getting magnitude of H from data in frequency domain
problem = createOptimProblem('fmincon',...
[x,fval] = fmincon(problem)
gs = GlobalSearch('Display','iter');
[x,fval] = run(gs,problem)
function J=obj(t1, t2,f,fr,fi)
for x=1:101 % number of frequency
for y=1:101 %number of t
Fr(x,y)=cos(2*pi*f(x)*t(y)); %real number of F
Fi(x,y)=-i*sin(2*pi*f(x)*t(y)); % imaginary number of F
a=lsqminnorm(A,B) ; % solve tp get a set of a
J=sum((a-abs_H))^2 ;% to find the minimum of J from measured data
Rik le 13 Mai 2020
There are several problems with your code. The one causing the error is that you are using t in your inner loop in your obj function. It also looks like that nested loop could be an array operation, but without your data it is hard to confirm.
Speaking of data: you are poofing variables into existance with those load operations. You should load to a struct instead. That way you can show where each variable is coming from.
As a last point: don't use clear all. The usefulnes of close all is also questionable here, as you don't open any figures. If you want to clear your variables, use clear or clearvars. Outside of debugging you should be using functions to keep your workspace clean.