Plotting Summation Function in matlab
Afficher commentaires plus anciens
Hi There,
I am trying to plot my function to see the expected behavior but I am running into trouble. It says the arrays dont match but I cant figure out why. Could someone please help me with this? I think my approach is right but I could be making it more complicated than it needs to be
%% Graphing mathematical model %%
clear all
t = 0:1000;
plot(t,f(t),'--')
hold off
grid
title('Release')
legend('Theoretical')
xlabel('Time (sec)')
ylabel('Concentration (mg/mL)')
function Cal = f(t)
n = 0:250; % Number of summations
Cao = 22.4;
L = 0.01;
Vp = 1*1*2*L;
Dab = .000000468;
Vl = 40;
%Belows is the concentration profile
sum_parts = ((3.*(2.*n+1).*pi.*sin(((2.*n+1).*pi)./2))./(((2.*n+1).*pi)+sin((2.*n+1).*pi))) .* exp(-(((2.*n+1).^2).*(pi.^2).*Dab.*t)/(4.*(L.^2))) .* (sin(((2.*n+1).*pi))./((2.*n+1).*pi)); %Summation
Cal = ((Cao.*Vp)./Vl).*(1-(2./L).*sum(sum_parts,2)); %Final Function
end
Any help is greatly appreciated!!!
-Daniel
Réponse acceptée
Plus de réponses (1)
Chandler Hall
le 9 Nov 2022
Does adding the line:
[n, t] = meshgrid(n, t);
sum_parts = ...
produce the desired output?
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!