[英]Uneven looping and iteration in Matlab
I am a beginner in MATLAB and I am encountering the following problem. 我是MATLAB的初学者,遇到以下问题。 I am trying to write a code that will run the x first then after each 4 runs, k increments by 1. I have searched for the solution, but could not find one.
我正在尝试编写一个代码,该代码将首先运行x,然后每运行4次,k递增1。我已经搜索了解决方案,但找不到一个。
a=[1;2;3;4];
b=[8;4;6;7];
k=[7;4;5;6;7;8;9];
for i = 1:1:4
for j = 1:1:7
m=a[i]+ b[i]*k[j]
end
end
my equation is M=a(x)+b(x)*k(t) where x=1:4 and t=1:7 我的方程是M = a(x)+ b(x)* k(t)其中x = 1:4和t = 1:7
Like : 喜欢 :
1+8*7 1 + 8 * 7
2+4*7 2 + 4 * 7
3+6*7 3 + 6 * 7
4+7*7 4 + 7×7
Then 然后
1+8*4 1 + 8×4
2+4*4 . 2 + 4 * 4。 .
。 .
。
and so on. 等等。
Can anyone please help on this? 有人可以帮忙吗? Thank you
谢谢
Here is the final code I have. 这是我的最终代码。 Thank you again for the help.
再次感谢您的帮助。
a=[1;2;3;4];
b=[8;4;6;7];
k=[7;4;5;6;7;8;9];
for j = 1:1:7
for i = 1:1:4
m=a(i)+ b(i)*k(j)
end
end
Kind regards 亲切的问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.