Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Applying different equations to sections of a column using a for loop

1 回表示 (過去 30 日間)
Kimberly Hess
Kimberly Hess 2020 年 4 月 6 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi,
Could anyone tell me how to apply a linear function (I know the coeeficients a and b) to a section of a col and another set of coefficents to another section of the col.
For example my col is 300 rows long. I want to apply y=a1x+b1 to 1 through 100, y=a2x+b2 to rows 101 through 200...
Thanks!
  2 件のコメント
darova
darova 2020 年 4 月 6 日
I don't understood. You have 300 coefficients or you have 300 values of x? What is col?
Kimberly Hess
Kimberly Hess 2020 年 4 月 6 日
The column represents time it counts up by 1 in each row. for a section of rows i need to apply the function to modify how it counts.

回答 (1 件)

darova
darova 2020 年 4 月 6 日
What about for loop?
for i = 1:300
if i <= 100
y(i) = a1*x(i)+b1(1);
elseif i <= 200
y(i) = a2*x(i)+b2(1);
elseif
y(i) = a*x(i)+b(1);
end
end
plot(x,y)
  1 件のコメント
Kimberly Hess
Kimberly Hess 2020 年 4 月 6 日
you got me on the right path! thanks!

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by