Heated-Rod Equation Recursive Question
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
AFD
el 5 de Dic. de 2020
Respondida: Shadaab Siddiqie
el 9 de Dic. de 2020
investigating the heat rod function.
Length = 50 cm uniform intiial temperature u0 = 100dC and thermal diffusivity k = 0.15. I was given the following code in the text, and it is fine until I put x into the sine term.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/447188/image.jpeg)
it says my error is in line 8. I know it is the x.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/447193/image.jpeg)
How can I get the correct input arguements? Also how would I get the graphs of u(x, 30) abd u(25,t)?
0 comentarios
Respuesta aceptada
Shadaab Siddiqie
el 9 de Dic. de 2020
It looks like you want to create function in a file and run it. Refere Create function in files for more information. Here is the code
function u = expand(x,t)
k = .15;
L = 50;
u0 = 100;
S = 0;
N= 50;
for n = 1:2:2*N+1
S = S + 1/n*exp((-n^2)*(pi^2)*k*t/(L^2))*sin((n*pi*x)/L);
end
u=(4*u0*S)/pi;
end
To plot you can run
a1 = expand(1:30,30);
a2 = expand(25,1:30);
plot(a1);
plot(a2);
from the command line or from another file.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Object Properties 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!