for x=1:0.5:20
how can store the value for this type of for loop.

6 Comments

madhan ravi
madhan ravi on 27 Nov 2018
Edited: madhan ravi on 27 Nov 2018
If you show the calculation we can vectorize it even without a loop if there is a possibility.
for i=1:0.5:20
Base =(BaseValue.inputSingleScan-1.63)*(327/10)*100;
Top = (TopValue.inputSingleScan-1.63)*(327/10)*100;
PI1 = abs(Top - Base);
this is calculation.
BaseValue.inputSingleScan ? provide the datas
data scan from sensor.
is it stored or live data?
live data...i want store the data every time loop...then find out the maximun value.

Sign in to comment.

 Accepted Answer

madhan ravi
madhan ravi on 27 Nov 2018
Edited: madhan ravi on 27 Nov 2018
EDITED
x=1:0.5:20;
n=numel(x);
Base=cell(1,n); % PRE-ALLOCATION
Top=cell(1,n);
PI1=cell(1,n);
for i=1:n
Base{i} =(BaseValue.inputSingleScan-1.63)*(327/10)*100;
Top{i} = (TopValue.inputSingleScan-1.63)*(327/10)*100;
PI1{i} = abs([Top{i}] - [Base{i}]);
end
values=[PI1{:}];
max_value=max(values);

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 27 Nov 2018

Edited:

on 27 Nov 2018

Community Treasure Hunt

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

Start Hunting!