Matrix dimensions must agree in a function with the sum
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello everybody.
Sorry for a stupid question but can't resolve this problem.
How can I avoid the error "Matrix dimensions must agree" without implementation of two loops for two variables?
The code is below.
function z=coeff
n=0:1:100000;
t=linspace(0.5,1.25,100);
G=linspace(0.1,1,100);
[t G] = meshgrid(t,G);
b11= @(t, G) (pi*t.*(sum((((2*n+1).*pi.*t)+G).^4./(((2*n+1).*pi.*t).^3.*(((2*n+1).*pi.*t)+2*G).^4)))+...
pi*t*(sum((((2*n+1).*pi.*t)+G).*G.*(G.^2+3*G.*((2*n+1).*pi.*t)+((2*n+1).*pi.*t).^2)./(((2*n+1).*pi.*t).^3.*(((2*n+1).*pi.*t)+2*G).^4))));
z1=b11(t,G);
contourf(t,G,z1);
colormap jet
colorbar
set(gca,'FontName','Times New Roman','FontSize',34)
end
Many thanks in advance.
1 comentario
Torsten
el 18 de En. de 2022
Insert the lines
size(t)
size(G)
size(n)
after the call to meshgrid.
These sizes must be equal in order for the function b11 to work. In your case, they are different.
Respuestas (0)
Ver también
Categorías
Más información sobre Contour Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!