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

 채택된 답변

Torsten
Torsten 2021년 12월 14일
편집: Torsten 2021년 12월 14일

0 개 추천

function r = myParFun(p,A,B,C,y)
x = A*p(1).* exp( B*p(2)) .*exp( C*p(3));
r = myPearsonCoeff(x,y);
%since optimization toolbox minimizes but we want to maximize
r = -r;
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2021년 12월 14일

댓글:

2021년 12월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by