我想写一个代码,给我一个 [5x5] 矩阵, 包含每个步骤的“ ec” 值。 但在这里我只能返回它的最后值 。 您能帮我吗?
谢谢你的关心
R = [0.13, 0.131, 0.132, 0.133, 0.134];
k = [1, 1.5, 2, 2.5, 3];
a = 3*60*6/1000;
for i=R
ec = 30 * (i*a + i*a*k/100)
endfor
我想写一个代码,给我一个 [5x5] 矩阵, 包含每个步骤的“ ec” 值。 但在这里我只能返回它的最后值 。 您能帮我吗?
谢谢你的关心
R = [0.13, 0.131, 0.132, 0.133, 0.134];
k = [1, 1.5, 2, 2.5, 3];
a = 3*60*6/1000;
for i=R
ec = 30 * (i*a + i*a*k/100)
endfor
看起来像你想要的东西一样
ec = zeros(5);
R = [0.13, 0.131, 0.132, 0.133, 0.134];
k = [1, 1.5, 2, 2.5, 3];
a = 3*60*6/1000;
for i_=1:length(R)
for j_=1:length(k)
ec(i_,j_) = 30 * (R(i_)*a + R(i_)*a*k(j_)/100);
end
end
除非我误解了您的问题。 这将返回 5x5 矩阵 < code> ec 。
循环注释 : 您应该避免使用 < code> > i code > 作为计数器, 因为预定义此值等于 sqrt (-1), 如果您重新指派它, 可能会有问题 。 添加加下划线可以避免此问题 。
So I have this function that I m trying to convert from a recursive algorithm to an iterative algorithm. I m not even sure if I have the right subproblems but this seems to determined what I need in ...
I am running into some serious memory leaks in one of my applications I am building. I have a UINavigatonController that is inside a UITabBarview. Inside the NavView is a MKMap view. When you click an ...
I m using a foreach loop to process a large set of items, unfortunately it s using alot of memory. (probably because It s doing a copy of the array). Apparently there is a way to save some memory with ...
I have got an xml file that brings text into a flash movie in the form of an array, I need to population some textboxes and want to do this using a for loop. My loop look like this: for(var i=...
Note: I added actual code snippets. Just scroll to end. // files is created by a OpenFileDialog. public void Function(String[] files, ...) { for(int i; i<files.Length; i++) { ...
I am having some trouble creating a for loop within a constructor to iterate over a map and an array at the same time. Here, it is indicated that this cannot be done with an enhanced for loop. I have ...
Every so often on here I see someone s code and what looks to be a one-liner , that being a one line statement that performs in the standard way a traditional if statement or for loop works. I ...
I ve read similar posts, but still didn t find a solution for myself. Basically I have an array with countries+towns in PHP and I need to show them on the map with markers. Here is my code: function ...