How to solve loop equation with given data
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear all,
I want to solve the equation below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/208120/image.jpeg)
first column of excel sheet is 'a' and 2nd column is 'b' coresponding to 'a'. For each a, there is m in the interval 0 to 3 with increment of 0.01 (m=0:0.01:3). How to solve ?
6 Kommentare
Adam Danz
am 13 Mär. 2019
The reason it stopped working is because you changed the size of 'm' but didn't change the size of 'eff'. I added a solution below that corrects this and allows you to use any size of 'm' without needing to change the size of 'eff'.
Antworten (1)
Adam Danz
am 13 Mär. 2019
Bearbeitet: Adam Danz
am 25 Mär. 2019
(continuing from the comments under the question to that the question is answered).
The more responsible way to initialize the loop variable is by using variables rather than hard-coding the variable size.
a = 1:1000;
b = 1:1000;
m = 0:0.01:3
n = 421; %number of loops
eff = zeros(n,length(m)) %here we use 'n' and the size of 'm' to define 'eff'
for i=1:n
eff(i,:) = ((0.65.*(a(i)-m-0.3).*b(i)))./10 ;
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Sources finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!