How could I code for loop with this values?
    4 次查看(过去 30 天)
  
       显示 更早的评论
    
Hi guys! I need a simple help from you. 
I want to create a for loop with nested if-else condition. Afterthat I want to plot them. Could you guys help me please!  I have written the pseudocode below.  I need the coding based on this. Please help me out.
Thank you in advance.
%'A' consists some values (e.g. 40, 60, 30, 80, 70, 50, 90, 30);
for A % it will take first 2 values 
% 'B' is the maximum value consisting of 2 values from 'A' 
% e.g. max (40,60) = 60 then this 60 will be first value of A and last
% value will be 30 so max(60,30) is 60. Afterthat first value is 60 and 2nd value is 80 
% so, max(60,80) is 80 likewise. 
     B = max (A);
% then 'C' is the last value from 'A' which is taken to get the 'B', will be assigned to 'C'.    
    C = 60; % for 2nd itaration C = 30, for 3rd C = 80, for 4th C = 70, for 5th C = 50 and so on.. 
    % If C reduces 30% of B then,
        x = C/10
        fprintf ('This is your value %d',x );
    else
        fprintf ('This is not your value %d',x );
    end 
end
plot ('x' vs simulation time)
3 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


