I want to create for different values of 'k' with implementation of time delay 'tp1' and want to get graphs for different k values and sum of k values. I have done for k= 2 and k=3 but I want to repeat this using loop. Please suggest any better ideas.
Thanking you
susmita

 채택된 답변

Tarunbir Gambhir
Tarunbir Gambhir 2021년 5월 26일

0 개 추천

You can use for loop to automate this task. For example, "k" ranging from 2 to 10 in steps of 1 can be done in the following manner:
y2series = zeros(length(y2),10);
y2series(:,1) = y2;
for k=2:10
y2P = zeros(size(y2));
tP = ((k-1)*pi*epsilon)/eta;
index_P = round(tP/dt)+1;
y2P(index_P:end) = y2(1:(end-index_P+1));
y2series(:,k) = y2P;
figure(k);
plot(t,y2,'-.m','LineWidth',2);grid on;
xlabel('Time','Fontname','times','Fontsize',12);ylabel('Dimensionless Displacement','Fontname','times','Fontsize',12);
ha=gca;set(ha,'linewidth',1.5,'FontName','times','FontSize',12,'Box','on');
hold on
for i = 2:k
plot(t,y2series(:,i),'--','LineWidth',2);grid on;
hold on
end
plot(t,sum(y2series,2),'b','LineWidth',2);grid on;axis([0 10 -0.1 0.1]);
end

댓글 수: 5

Susmita Panda
Susmita Panda 2021년 5월 27일
Thanks a lot sir.
Susmita Panda
Susmita Panda 2021년 5월 27일
Sir, how to loop an ode45 function?
Susmita Panda
Susmita Panda 2021년 5월 27일
If I want to repeat for different velocity, I want to do looping of ode function.
Tarunbir Gambhir
Tarunbir Gambhir 2021년 5월 28일
You can refer this question for looping through ode45 solver.
Susmita Panda
Susmita Panda 2021년 5월 28일
@Tarunbir Gambhir Thanks. Sir I would request you to look my another problem in IFFT which I raised in the forum. I need help please.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

질문:

2021년 5월 23일

댓글:

2021년 5월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by