قوانين الملتقى | نسيت كلمة المرور
◄   شارك في دعم الملتقى 

◄  للإعلان أو لطلبات البحث عن موظفين
 

أنت غير مشترك بملتقى المهندسين العرب .. للاشتراك اضغط هنا 

http://www.arab-eng.org/vb/uploaded2009/1/1268238098.gif

   مجموعات بريدية مدعومة من ملتقى المهندسين : قروب الهندسة الصناعية - قروب هندسة التعدين و البترول

العودة   ملتقى المهندسين العرب - أول ملتقى هندسي عربي > الهندسة الميكانيكية > هندسة الميكاترونكس > برنامج الـ Matlab


plot inside loop!!!


رد
 
LinkBack أدوات الموضوع
  #1 (permalink)  
قديم 07-02-2010, 09:33 PM
الصورة الرمزية beho86
عضو
 


Unhappy plot inside loop!!!

 

Hey guys,
I have a question: problem statement is:
Use Euler's method, and assume a cooling constant r = 0.2 , initial temperature of 86 C, and room temperature at 17 C. Choose your time
step h judiciously and integrate to 5 minutes.

You can add some cream which will drop the temperature instantly by 5 C.
(a) Now, add the cream at the beginning. Plot your results. What is the temperature after 5 min?
(b) Add the cream at the end. Plot the results (preferably on the same figure). What is the temperature at the end?
كود:
r=0.2;           %Cooling Constant
T=86 ;           % Initial Temperature   
t=0   ;             
Ts=17;           %Surrounding Temperature
h=0.1  ;         %Step Size
nsteps=300  ;    

for i=0:nsteps
   fprintf('%0.2f   %0.3f\n',t,T)    
   dT=-r*h*(T-Ts)  ;
   T=T+dT   ;     
   t=t+h;   
end
plot(t,T)
I need to store the variables into an array, so that I can print it out, not just the last point of the loop.

second: if I want to add cream at the beginning: I need to subtract 5 from the second element.

Third: if I want to add cream at the end: I need to subtract 5 from the last element.

 

آخر مواضيعي 0 plot inside loop!!!
0 Calculus Concepts and Contexts 2nd Ed solutions
0 Need General Chemistry Student Solutions Manual,by Darrell D. Ebbing
0 Guys, You must check this website 4 Eng.!!
رد مع اقتباس
قديم 07-02-2010, 11:24 PM   رقم المشاركة : [2 (permalink)]
عضو
الصورة الرمزية Abdurauf
 

Abdurauf متميز

r=0.2; %Cooling Constant
T=86 ; % Initial Temperature
t=0 ;
Ts=17;
%Surrounding Temperature
h=0.1 ; %Step Size
nsteps=300 ;

for i=0:nsteps
fprintf(
'%0.2f %0.3f\n',t,T)
dT=-r*h*(T(i+1)-Ts) ;
T(i+2)=T(i+1)+dT ;
t(i+2)=t(i+1)+h;
end
plot(t,T)
t
T



Abdurauf غير موجود حالياً   رد مع اقتباس
قديم 07-02-2010, 11:32 PM   رقم المشاركة : [3 (permalink)]
عضو
الصورة الرمزية beho86
 

beho86

Hello Abdurauf,
It worked well, I just made a small change, in the print statement:
كود:
r=0.2; T=86 ; t=0 ; Ts=17; h=0.1 ; nsteps=3000 ;

for i=0:nsteps
dT=-r*h*(T(i+1)-Ts) ;
T(i+2)=T(i+1)+dT ;
t(i+2)=t(i+1)+h;
fprintf('%0.2f %0.3f\n',t(i+1),T(i+1))
end
plot(t,T)
Now, how the program will differs, when I add the cream at the beginning or at the end of the 5 min?!
Beginning, I should subtract 5 from the first cell, and update the rest of the cells.
End, subtract 5 from the last cell only.

Thanks so much for your help


التعديل الأخير تم بواسطة beho86 ; 08-02-2010 الساعة 12:46 AM. سبب آخر: update
beho86 غير موجود حالياً   رد مع اقتباس
قديم 09-02-2010, 10:07 PM   رقم المشاركة : [4 (permalink)]
عضو
الصورة الرمزية أسماء الكون
 

أسماء الكون يستحق التميز

تستطيع مباشرة أن تضع :

t=0:0.1:30

بدون إدخالها في الحلقة التكرارية



أسماء الكون غير موجود حالياً   رد مع اقتباس
رد

الكلمات الدلالية (Tags)
inside, loop!!!, plot

أدوات الموضوع

تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة
Trackbacks are متاحة
Pingbacks are متاحة
Refbacks are متاحة

الانتقال السريع

المواضيع المتشابهة
الموضوع كاتب الموضوع المنتدى مشاركات آخر مشاركة
ANSYS Example: Axisymmetric Analysis of a Pressure Vesse Eng-Faten الهندسة الميكانيكية - عام 7 14-02-2010 12:32 PM
close loop speed control اسلام محمد البطران الهندسة الكهربائية - عام 0 12-10-2009 10:37 PM
Log Plot أوج الهندسة الهندسة المـدنيـة - عام 2 11-09-2009 04:42 PM
urgent: for loop :( u.student برنامج الـ Matlab 7 23-06-2009 04:01 AM
"Natural" Antennas علي العزام الهندسة الكهربائية - عام 0 14-04-2008 04:00 PM


الساعة الآن 06:17 PM.


Powered by vBulletin® / BoxLink.NET
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd
جميع المواضيع المطروحة لا تمثل رأي إدارة الملتقى ، بل تعبر عن رأي كاتبيها .

Content Relevant URLs by vBSEO 3.3.1