for loop to use iteration and time
    조회 수: 13 (최근 30일)
  
       이전 댓글 표시
    
Hello all,
I'm quite new user of Matlab.
My question is;
T_pu=ones(iter,1)*293;
T_pu_time=ones((total_t/delta_t)+1,1)*293;
delta_t=1;
total_t=36000;
iter=5;
for t=1:delta_t:total_t
    for i=1:iter
        x_tpu(i)=(T_e-T_pu(i))/(2));
        y_tpu(i)=(T_x-T_pu(i))/(5);
        T_pu(i+1)= T_pu(i)+(x_tpu(i)+y_tpu(i)))*(t/2);
        if i==iter
        T_pu(iter)=T_pu_time(t);
        end
    end
end
Shortly, I want to start from time=1 and T_pu with iteration (5 times), 5th iteration is equal of my first T_pu_time(t) matrix element, then it will continue with t=2 and 5 iteration .....
Can you please help me or share with me any example how can I solve this issue?
댓글 수: 2
  dpb
      
      
 2021년 1월 24일
				Not clear what you're trying to do, sorry...
T_pu=ones(iter,1)*293;
T_pu_time=ones((total_t/delta_t)+1,1)*293;
delta_t=1;
total_t=36000;
iter=5;
in the above, however, you used iter to preallocate two arrays, but didn't define it until afterwards...so whatever iter was the last time you ran the code before would have just been the left over value.
What's the *293 intended to do in those two statements?  Why would you preallocate arrays containing the value 293 which is what that does?
답변 (1개)
  Gaurav Garg
    
 2021년 1월 27일
        Hi Murat,
In order to assign 5th element of T_pu to 1st element of T_pu_time, 10th element of T_pu == 2nd element of T_pu_time and so on..., you can follow the code segment given below -
for i=1:n
T_pu_time(i) = T_pu(i*5);
end
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!