Matrix dimensions must agree in a function with the sum
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Torsten
le 18 Jan 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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!