What changes should i have to make in my code to remove the error (“Error using contourf Z must be at least a 2×2 matrix.”)
%——Creating a strain matrix———–%
E = zeros(2*(size(K1,1)-1),2*(size(K1,1)-1))
for j = 1: (size(K1,1)-1)
for i = 1: (size(K1,1)-1)
v = [zpk1(j,i);zpk2(j,i);zpk1(j,i+1);zpk2(j,i+1);zpk1(j+1,i+1);zpk2(j+1,i+1);zpk1(j+1,i);zpk2(j+1,i)];
e1= strain1(v);
e2= strain2(v);
e3= strain3(v);
e4= strain4(v);
E((2*j-1),(2*i-1)) = e1(1);
E((2*j-1),2*i) = e2(1);
E(2*j,(2*i-1)) = e4(1);
E(2*j,2*i) = e3(1);
end
end
su = round(4*d/g)+1 ;
r = E((((su-1)- round(d/g)):-1:1),(su-1));
p = E((((su-1)- round(d/g)):-1:1),(su));
st = (p+r)./(1.5*(10)^(-4));
m = g*(size(r)-1);
H = 0:g:(m);
h = H./10;
writematrix(st)
type ‘st.txt’;
writematrix(h)
type ‘h.txt’;
plot(h,st)
xlim([0 1.5])
xlabel("X2/d",’fontsize’,14)
ylabel("Normalised Strain along vertical path", ‘fontsize’,13)
legend("d/w = 0.5")
saveas(gcf,’plot.png’)
contourf(st)
colorbar
saveas(gcf,’contour.png’)%——Creating a strain matrix———–%
E = zeros(2*(size(K1,1)-1),2*(size(K1,1)-1))
for j = 1: (size(K1,1)-1)
for i = 1: (size(K1,1)-1)
v = [zpk1(j,i);zpk2(j,i);zpk1(j,i+1);zpk2(j,i+1);zpk1(j+1,i+1);zpk2(j+1,i+1);zpk1(j+1,i);zpk2(j+1,i)];
e1= strain1(v);
e2= strain2(v);
e3= strain3(v);
e4= strain4(v);
E((2*j-1),(2*i-1)) = e1(1);
E((2*j-1),2*i) = e2(1);
E(2*j,(2*i-1)) = e4(1);
E(2*j,2*i) = e3(1);
end
end
su = round(4*d/g)+1 ;
r = E((((su-1)- round(d/g)):-1:1),(su-1));
p = E((((su-1)- round(d/g)):-1:1),(su));
st = (p+r)./(1.5*(10)^(-4));
m = g*(size(r)-1);
H = 0:g:(m);
h = H./10;
writematrix(st)
type ‘st.txt’;
writematrix(h)
type ‘h.txt’;
plot(h,st)
xlim([0 1.5])
xlabel("X2/d",’fontsize’,14)
ylabel("Normalised Strain along vertical path", ‘fontsize’,13)
legend("d/w = 0.5")
saveas(gcf,’plot.png’)
contourf(st)
colorbar
saveas(gcf,’contour.png’) %——Creating a strain matrix———–%
E = zeros(2*(size(K1,1)-1),2*(size(K1,1)-1))
for j = 1: (size(K1,1)-1)
for i = 1: (size(K1,1)-1)
v = [zpk1(j,i);zpk2(j,i);zpk1(j,i+1);zpk2(j,i+1);zpk1(j+1,i+1);zpk2(j+1,i+1);zpk1(j+1,i);zpk2(j+1,i)];
e1= strain1(v);
e2= strain2(v);
e3= strain3(v);
e4= strain4(v);
E((2*j-1),(2*i-1)) = e1(1);
E((2*j-1),2*i) = e2(1);
E(2*j,(2*i-1)) = e4(1);
E(2*j,2*i) = e3(1);
end
end
su = round(4*d/g)+1 ;
r = E((((su-1)- round(d/g)):-1:1),(su-1));
p = E((((su-1)- round(d/g)):-1:1),(su));
st = (p+r)./(1.5*(10)^(-4));
m = g*(size(r)-1);
H = 0:g:(m);
h = H./10;
writematrix(st)
type ‘st.txt’;
writematrix(h)
type ‘h.txt’;
plot(h,st)
xlim([0 1.5])
xlabel("X2/d",’fontsize’,14)
ylabel("Normalised Strain along vertical path", ‘fontsize’,13)
legend("d/w = 0.5")
saveas(gcf,’plot.png’)
contourf(st)
colorbar
saveas(gcf,’contour.png’) matlab, fem, abaqus MATLAB Answers — New Questions