what changes can be done in the code

1 回表示 (過去 30 日間)
Manav Divekar
Manav Divekar 2021 年 12 月 7 日
コメント済み: Olivia Alia 2022 年 4 月 15 日
i have to return values of diff between drug and placebo for given exel either for systolic or diastolic
function [diffdrug,diffplacebo] = xls_clinicaltrialbp(filename, bptype)
%by Manav Divekar, 2021-12-07
if ~exist('bptype','var')
bptype = 'Systolic';
end
treatment = readtable(filename,'sheet','Sheet1');
drugs = 0;
beforedia = 0;
beforesys = 0;
afteredia = 0;
aftersys = 0;
d = strcmpi(treatment.Properties.VariableNames,'Treatment');
drugs = treatment{:,d};
bd = strcmpi(treatment.Properties.VariableNames,'DiastolicBefore');
ad = strcmpi(treatment.Properties.VariableNames,'DiastolicAfter');
bs = strcmpi(treatment.Properties.VariableNames,'SystolicBefore');
as = strcmpi(treatment.Properties.VariableNames,'SystolicAfter');
beforedia = treatment{:,bd};
beforesys = treatment{:,bs};
afteredia = treatment{:,ad};
aftersys = treatment{:,as};
beforediap = beforedia(strcmpi(drugs,'Placebo'));
beforesysp = beforesys(strcmpi(drugs,'Placebo'));
afterediap = afteredia(strcmpi(drugs,'Placebo'));
aftersysp = aftersys(strcmpi(drugs,'Placebo'));
beforediad = beforedia(strcmpi(drugs,'drugs'));
beforesysd = beforesys(strcmpi(drugs,'drugs'));
afterediad = afteredia(strcmpi(drugs,'drugs'));
aftersysd = aftersys(strcmpi(drugs,'drugs'));
if (bptype == 'systolic')
diffdrug = beforesysd - aftersysd;
diffplacebo = beforesysp - aftersysp;
end
if (bptype == 'diastolic')
diffdrug = beforediad - afterdiad;
diffplacebo = beforediap - afterdiap;
end
Input :
[diffdrug,diffplacebo] = xls_clinicaltrialbp('clinicaltrialbp.xlsx')
or
[diffdrug,diffplacebo] = xls_clinicaltrialbp('clinicaltrialbp.xlsx','DIAStolic')

回答 (1 件)

Image Analyst
Image Analyst 2021 年 12 月 11 日
You need to use contains:
if contains(bptype, 'sys', 'IgnoreCase', true)
diffdrug = beforesysd - aftersysd;
diffplacebo = beforesysp - aftersysp;
end
if contains(bptype, 'dia', 'IgnoreCase', true)
diffdrug = beforediad - afterdiad;
diffplacebo = beforediap - afterdiap;
end
  1 件のコメント
Olivia Alia
Olivia Alia 2022 年 4 月 15 日
thank you so much for sharing this.thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeBiotech and Pharmaceutical についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by