matrix calculation have wrong answer
显示 更早的评论
I have the following code,
clear;
time = datestr(now,'dd-mm-yyyy HH-MM-SS');
input=xlsread('Book1.xlsx');
load('beta0_1.mat');
load('kbeta_bao_hoa.mat');
load('x_delta.mat');
load('kI');
load('Ka');
Z1 = 48;
Z2 = 40;
x = [221.1321 336.6439 0.6575 5.3102 345.8133 7.6177 9.5410 19.3115 0.7990 8.8932 17.1360 8.8941 8.8954 30.9960 2.0003 ];
y_test = linspace(0.5,4,100);
z_test = linspace(1, 10, 100);
[X,Y] = meshgrid(y_test,z_test);
m_k = - m_k_ranhTQ_1(x,input,beta0,kbeta_bao_hoa,x_delta,kI,Ka,time,Z1,Z2,X,Y);
surf(X,Y,m_k);
hold on;
m_k_x = - m_k_ranhTQ_1(x,input,beta0,kbeta_bao_hoa,x_delta,kI,Ka,time,Z1,Z2,1.419,5.545);
plot3(0.7990,8.8932,m_k_x,'.r','markersize',10);
m_k_ranhTQ_1 is a function with 1 ouput. When i run this script, m_k is a 100x100 matrix. The problem is the result in the m_k matrix have wrong answers. Like you can see in the script, i try to highlight the point (1.419; 5.545) on the surface of the 3d graph, but it is not even on the surface, it is way off. I try to go to the Workspace to check manually, and typing in the command window like:
m_k_x = - m_k_ranhTQ_1(x,input,beta0,kbeta_bao_hoa,x_delta,kI,Ka,time,Z1,Z2,X(100,100),Y(100,100))
and compare it with m_k (100,100), and it is not the same answer. I think m_k (x,y) = f[X(x,y); Y(x,y)]. I check and if i use low index, like
m_k_x = - m_k_ranhTQ_1(x,input,beta0,kbeta_bao_hoa,x_delta,kI,Ka,time,Z1,Z2,X(30,16),Y(30,16))
In this case, m_k_x = m_k(30, 16)
Can someone tell me where i did wrong and how can i fix this?
9 个评论
Bjorn Gustavsson
2022-2-20
How could we possibly? You will have to show the details of your m_k_ranhTQ_1 function for us to be able to help.
quan ng
2022-2-20
Catalytic
2022-2-20
I have attach all files needed to run the above script
Why so many? Why not put everything in one .mat file so it's easier for us to download?
quan ng
2022-2-20
quan ng
2022-2-20
Bjorn Gustavsson
2022-2-20
Another point you might consider is to write your code in "english".
It might seem a bit rude of me to suggest that your native tounge is not suitabel - but that's not what I insinuate. Once uppon a time I programmed in my native language, function and variable-names and comments. Then a colleague that did not speak my language tried to use/port the programme, which made me feel very rude. Since then I've stuck to working in english - even if neither of me nor my colleagues have it as a first language we can get by...
quan ng
2022-2-20
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!