Plotting Summation Function in matlab
古いコメントを表示
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
採用された回答
その他の回答 (1 件)
Chandler Hall
2022 年 11 月 9 日
Does adding the line:
[n, t] = meshgrid(n, t);
sum_parts = ...
produce the desired output?
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!