Problem - Optimization nonlinaer function
Afficher commentaires plus anciens
Hello.
I need help, to find p1, p2 and p3 to get the best Pearson correlation between x and y.
My function iz:
x= A*p1 * exp(B*p2)*exp (C*p3)
This is my code:
clear;
close all;
clc;
load('myData_all.mat');
%define A B C and y
y1 = MOS;
A1 = Metr_all;
B1 = QInitReb_all;
C1 = QBitRate_all;
%Due to different scales, rescale all data to have mean 0 and standard deviation 1
[y,ymean,ydev] = zscore(y1);
A = zscore(A1);
B = zscore(B1);
C = zscore(C1);
%define initial values for p
p0 = [0.5, 0.5, 0.5];
%Define the objective function as an anonymous function.
f = @(p)myParFun(p,A,B,C,y);
%Optimize for p
[p,fval] = fminunc(f,p0)
%Calculate x using calculated p
[r,x] = myParFun(p,A,B,C,y);
function [r,x] = myParFun(p,A,B,C,y)
x = A*p(1) * exp( B*p(2)) *exp( C*p(3));
r = myPearsonCoeff(x,y);
%since optimazation toolbox minimizes but we want to maximize
r = -r;
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Nonlinear Optimization dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!