# how can I plot the following function in matlab without symbolic toolbox?

4 visualizzazioni (ultimi 30 giorni)
nargess il 3 Gen 2014
Commentato: nargess il 3 Gen 2014
with Ts=300 , Ti=100 , L=1 , x=0:0.01:L, t=0.5 and a=0.1
I have written the following code but it doesn't work. can sb help me?
clc; clear all
Ts=300;
Ti=100;
a=0.1;
l=1;
Sum=0;
for x=0:0.01:l;
for m=1:1000000
S=((exp(-((m*3.14/l)^2)*0.05))*((1-(-1)^3.14)/(m*3.14))*sin(m*3.14*x));
Sum=Sum+S;
end
T=Ts+2*(Ti-Ts)*Sum;
plot(x,T)
hold on;
end
it should give me a sin like figure but it gives
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

the cyclist il 3 Gen 2014
Modificato: the cyclist il 3 Gen 2014
Looks pretty sinusoidal to me. You've only plotted a very small portion, though. Maybe try letting x run from -5 to 5 to see more of the domain?
Also, I think you can let m be something a lot smaller, and you will still see the limiting behavior well.
I notice in your formula you have (-1)^3.14 in one place where the formula has (-1)^m.
Finally, you can use "pi" in place of 3.14. MATLAB understands what that means.
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
nargess il 3 Gen 2014
thank you for your attention. yes I edit that part(the ^pi part)it's again out of range . unfortunately I can not change the limits. because the problem has defined them. since two sides of wall are at the same temperature, (and from the results of two numerical method), it's expected that temperature distribution must be symmetric in this interval. with the minimum at the middle.! but it's not!

Accedi per commentare.

### Più risposte (1)

Laurent il 3 Gen 2014
Modificato: Laurent il 3 Gen 2014
You set Sum=0 outside of the loop, which means that it will never be reset to 0 for a new value of x. I suggest to put it after the line 'for x=0:0.01:l'.
##### 2 CommentiMostra NessunoNascondi Nessuno
nargess il 3 Gen 2014
Thanks. yes that's right.. I am going to try it now.
nargess il 3 Gen 2014
YES! it was solved.thank you soooo much. it's really the accepted answer. thank you

Accedi per commentare.

### Categorie

Scopri di più su Mathematics in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by