Trying to write conditional if loop for an interval

cellcount1 = 1.41e6;
cellcount2 = 1.54e6;
avgcellcount = (cellcount1 + cellcount2)./2;
upplimit = (0.05.*avgcellcount) + avgcellcount;
lowlimit = avgcellcount - (0.05.*avgcellcount);
a = [avgcellcount];
b = avgcellcount(avgcellcount > lowlimit & avgcellcount <upplimit);
if (lowlimit < avgcellcount) && (avgcellcount < upplimit)
disp(Cell Counts are within 10% limit’);
else
disp(Cell Counts are outside of 10% limit’);
end
keep getting this error: parse error:
syntax error
>>> disp(‘Cell Counts are within 10% limit’); ^
parse error:
syntax error
>>> else ^
parse error:
syntax error
>>> disp(‘Cell Counts are outside of 10% limit’); ^
parse error:
syntax error
>>> end

回答 (2 件)

madhan ravi
madhan ravi 2018 年 11 月 2 日

0 投票

cellcount1 = 1.41e6;
cellcount2 = 1.54e6;
avgcellcount = (cellcount1 + cellcount2)./2;
upplimit = (0.05.*avgcellcount) + avgcellcount;
lowlimit = avgcellcount - (0.05.*avgcellcount);
a = [avgcellcount];
b = avgcellcount(avgcellcount > lowlimit & avgcellcount <upplimit);
if (lowlimit < avgcellcount) && (avgcellcount < upplimit)
disp('Cell Counts are within 10% limit');
else
disp('Cell Counts are outside of 10% limit');
end
Bruno Luong
Bruno Luong 2018 年 11 月 2 日
編集済み: Bruno Luong 2018 年 11 月 2 日

0 投票

This is not TeX or LaTeX
disp(Cell Counts are within 10% limit’);
MATLAB string quote is like this:
disp('Cell Counts are within 10% limit');

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2018 年 11 月 2 日

編集済み:

2018 年 11 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by