what changes can be done in the code

1 view (last 30 days)
Manav Divekar
Manav Divekar on 7 Dec 2021
Commented: Olivia Alia on 15 Apr 2022
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')

Answers (1)

Image Analyst
Image Analyst on 11 Dec 2021
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

Categories

Find more on Biotech and Pharmaceutical in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!