what changes can be done in the code
1 view (last 30 days)
Show older comments
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')
0 Comments
Answers (1)
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
See Also
Categories
Find more on Biotech and Pharmaceutical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!