function N1d = shapeFn1d(gp1d)
n1 = 0.5*(1-gp1d(1,1));
n2 = 0.5*(1+gp1d(2,1));
N1d = [n1, n2];
end
gp1d is a 2x1 array and I was expecting N1d to be a 1x2 array but it comes out to be as 2x2 array and I don't know why. Can someone please help me.
This is my gp1d
[-0.57735;
0.57735];
This is the N1d that the program displays
[0.78868, 0.21132;
0.21132, 0.78868];
This is the N1d I expected [ 0.78868, 0.78868 ];
Are you sure you don't have a typo somewhere? I copied and pasted your code and it seems fine, both in Octave and in Matlab:
>> system('cat shapeFn1d.m')
function N1d = shapeFn1d(gp1d)
n1 = 0.5*(1-gp1d(1,1));
n2 = 0.5*(1+gp1d(2,1));
N1d = [n1, n2];
end
ans = 0
>> gp1d=[-0.57735; 0.57735];
>> shapeFn1d(gp1d)
ans =
0.78868 0.78868
>>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.