Why I knock into a error when I want to get data from my double?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
晨
el 30 de Sept. de 2023
Editada: Walter Roberson
el 3 de Oct. de 2023
R = [[1 0.9954 0.9994 0.9989];
[0.9954 1 0.9926 0.9923];
[0.9994 0.9926 1 0.9977] ;
[0.9989 0.9923 0.9977 1]];
% 一级偏相关系数
R_PC1 = [PC1(1,2,3) PC1(1,2,4) PC1(1,3,2) PC1(1,3,4) PC1(1,4,2) PC1(1,4,3)
PC1(2,3,1) PC1(2,3,4) PC1(2,4,1) PC1(2,4,3) PC1(3,4,1) PC1(3,4,2)];
% 二级偏相关系数
R_PC2 = [PC2(1,2,3,4) PC2(1,3,2,4) PC2(1,4,2,3) PC2(2,3,1,4) PC2(2,4,1,3) PC2(3,4,1,2)];
% 计算一级偏相关系数
function[r] = PC1(a,b,c) % 在c不变的情况下,a和b之间的相关系数
r = (R(a,b)-R(a,c)*R(b,c))/sqrt((1-R(a,c)^2)*(1-R(b,c)^2));
end
function[r] = PC2(a,b,c,d) %在c,d不变的情况下,a和b之间的相关系数
r = (PC1(a,b,c)-PC1(a,d,c)*PC1(b,d,c))/sqrt((1-PC1(a,d,c)^2)*(1-PC1(b,d,c)^2));
end
This program knock into a error at line15 and it read'出错 coord>PC1 (第 15 行)'
检查对函数 'R' 的调用中是否存在不正确的参数数据类型或缺少参数。
It seems that MATLAB see the 'R' as a function rather than a Matrix
0 comentarios
Respuesta aceptada
Star Strider
el 30 de Sept. de 2023
In ‘PCI1’ you are referencing ‘R’ however you are not passing it to ‘PCI1’ as an argument.
Perhaps this —
R = [[1 0.9954 0.9994 0.9989];
[0.9954 1 0.9926 0.9923];
[0.9994 0.9926 1 0.9977] ;
[0.9989 0.9923 0.9977 1]];
% 一级偏相关系数
R_PC1 = [PC1(1,2,3,R) PC1(1,2,4,R) PC1(1,3,2,R) PC1(1,3,4,R) PC1(1,4,2,R) PC1(1,4,3,R)
PC1(2,3,1,R) PC1(2,3,4,R) PC1(2,4,1,R) PC1(2,4,3,R) PC1(3,4,1,R) PC1(3,4,2,R)]
% 二级偏相关系数
R_PC2 = [PC2(1,2,3,4,R) PC2(1,3,2,4,R) PC2(1,4,2,3,R) PC2(2,3,1,4,R) PC2(2,4,1,3,R) PC2(3,4,1,2,R)]
% 计算一级偏相关系数
function [r] = PC1(a,b,c,R) % 在c不变的情况下,a和b之间的相关系数
r = (R(a,b)-R(a,c)*R(b,c))/sqrt((1-R(a,c)^2)*(1-R(b,c)^2));
end
function [r] = PC2(a,b,c,d,R) %在c,d不变的情况下,a和b之间的相关系数
r = (PC1(a,b,c,R)-PC1(a,d,c,R)*PC1(b,d,c,R))/sqrt((1-PC1(a,d,c,R)^2)*(1-PC1(b,d,c,R)^2));
end
.
2 comentarios
Star Strider
el 3 de Oct. de 2023
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!