matrix calculation have wrong answer
Show older comments
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 Comments
Bjorn Gustavsson
on 20 Feb 2022
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
on 20 Feb 2022
Catalytic
on 20 Feb 2022
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
on 20 Feb 2022
quan ng
on 20 Feb 2022
Bjorn Gustavsson
on 20 Feb 2022
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
on 20 Feb 2022
Accepted Answer
More Answers (0)
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!