anyone can help me to short this looping ? because when I want to change setting it's take to long :(
clc; clear;
wmin = 0.4; wmax = 1.2;

댓글 수: 3

Rik
Rik 2017년 11월 9일
Are intentionally overwriting w every loop? Also, I would suggest converting this to logical indexing instead of a loop. It will be much faster.
Muhammad Hafiz
Muhammad Hafiz 2017년 12월 6일
thanks Rik :)
KL
KL 2017년 12월 11일
Please do not delete your question contents like this. Answers serve more like a FAQ/documentation with examples, now it doesn't make any sense.

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

 채택된 답변

KL
KL 2017년 11월 9일

0 개 추천

Rik is right, logical indexing will make it lot simpler and faster,
wmin = 0.4; wmax = 1.2;
it= 1:1000;
then pre-allocate w,
w = zeros(size(it));
then calculate w based on the value of it,
w(it<=425) = (150 - it(it<=425))./150.*(wmin-wmax)+wmax;
w(it>425&it<=550) = wmax-(wmax-wmin)./150.*(it(it>425&it<=550)-150);
w(it>550&it<=650) = (100-(it(it>550&it<=650)-550))./100.*(wmin-(wmax-0.6))+(wmax-0.6);
and so on! Now you know how to write your remaining equations the same way.

추가 답변 (0개)

카테고리

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

태그

질문:

2017년 11월 9일

댓글:

KL
2017년 12월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by