MATLAB: The thefunction return zero elements

matrix with zero elements

Hi all; I have a function which should return a R_gradient matrix. I identify its elements but when I call myfunction it returns zero elements. I checked the passing parameter kc there is nothing wrong with it and the values of the elements are calculated correctly when i calculated them separately (i.e. Rg22,….,Rg55). can any one explain what wrong with myfunction. Regards
function R_gradient = myfunction(kc)
r1 = 1e+5;
r2 = 0.5;
q = 1e-5;
ks = kc(1);
cs = kc(2);
param.ms = 325;
param.mus = 65;
param.kus = 232.5e3;
param.ct = 0 ;
Rg22=r2*(cs/param.ms)^2;
Rg23=-r2*(cs/param.ms)*(ks/param.ms);
Rg24=-r2*(cs/param.ms)^2;
Rg25=r2*cs/(param.ms^2);
Rg32=-r2*(cs/param.ms)*(ks/param.ms);
Rg33=r2*(ks/param.ms)^2;
Rg34=r2*(cs/param.ms)*(ks/param.ms);
Rg35=-r2*ks/(param.ms^2);
Rg42=-r2*(cs/param.ms)^2;
Rg43=r2*(cs/param.ms)*(ks/param.ms);
Rg44=r2*(cs/param.ms)^2;
Rg45=-r2*cs/(param.ms^2);
Rg52=r2*cs/(param.ms^2);
Rg53=-r2*ks/(param.ms^2);
Rg54=-r2*cs/(param.ms^2);
Rg55=q+r2/(param.ms^2);
R_gradient = [
r1 0 0 0 0;...
0 Rg22 Rg23 Rg24 Rg25;...
0 Rg32 Rg33 Rg34 Rg35;...
0 Rg42 Rg43 Rg44 Rg45;...
0 Rg52 Rg53 Rg54 Rg55];
end

Best Answer

I don’t know what your ‘kc’ is, but when I do this:
kc = [1 2];
R_gradient = myfunction(kc)
I get this:
R_gradient =
1e+05 0 0 0 0
0 1.8935e-05 -9.4675e-06 -1.8935e-05 9.4675e-06
0 -9.4675e-06 4.7337e-06 9.4675e-06 -4.7337e-06
0 -1.8935e-05 9.4675e-06 1.8935e-05 -9.4675e-06
0 9.4675e-06 -4.7337e-06 -9.4675e-06 1.4734e-05
I don’t understand the problem. What do you want it to do?
Related Question