help me with this for loop please

1 次查看(过去 30 天)
soloby
soloby 2015-6-23
评论: soloby 2015-6-25
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 个评论
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
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by