help me with this for loop please

x = -10:0.1:10;
y = 0:0.005:1;
minNmax1 = 0:.005:1;
upper_1 = 0:.005:1;
y2 = 0:.005:1;
f1 = trapmf(x,[-2 0 0 2].');
minNmax1 = zeros(length(x), 2);
for k = 1 :length(y)
minNmax1(k,:) = [min(x),max(x)];
end
I'm trying to get [min(x),max(x)] for 201 values of y but this will only give me 1 answer [-10 10] which i assume is the first iteration?
help!

댓글 수: 6

Katalin
Katalin 2015년 6월 23일
Sorry it is not clear what you would like in your variable. min(x) and max(x) are both constants, it will fill your 201x2 matrix with -10 in the first column and 10 in the second. Could you please explain more what you would like to achieve?
soloby
soloby 2015년 6월 23일
편집: soloby 2015년 6월 23일
hi, thanks for the reply.
I'm trying to get minimum and maximum values of my function f1 (triangular tooth) for 200 different values of y.
i.e.,
@ y = 0 min(x), max(x)
@ y = 0.005 min(x), max(x)
@ y = 0.01 min(x), max(x)
and so forth. all the way up to y = 1
Jan
Jan 2015년 6월 23일
편집: Jan 2015년 6월 23일
I cannot understand your notation. What does "@ y = 0.01 min(x), max(x)" mean? There is no "y" in this expression on the right hand side. What does the "y=0.01" part mean? Which y-values do you want to check and do you think that any y-value is exactly 0.01?
Perhaps you want "f1" to appear anywhere?
Katalin
Katalin 2015년 6월 23일
How does f1 depend on y?
soloby
soloby 2015년 6월 23일
편집: soloby 2015년 6월 23일
my function f1 ranges from 0 to 1. if you plot(x,f1) it can be seen.
I need to split my f1 values (0 to 1) into 201 pieces and find the upper and lower x values for each iterations of y. Think of fuzzy logic, it is similar to how it is solved.
Easy concept, but I'm afraid a lot harder to execute.
so my f1 is 0 to 1
I want to divide it up into equal numbers (201 in my case)
at each iteration, I want to find the x values Please someone help!
soloby
soloby 2015년 6월 23일
Check my picture please, I need to find those starred points for all the red lines (201 of them)

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

답변 (1개)

Muhannad
Muhannad 2015년 6월 24일

0 개 추천

will min(x) always be the same number as x is not changing? you can use repmat(min(x), 201,1)) if that is the case

댓글 수: 1

soloby
soloby 2015년 6월 25일
min(x) will be the same for each iterations of y but I need it for all 201 y's.

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

카테고리

도움말 센터File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

질문:

2015년 6월 23일

댓글:

2015년 6월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by