what changes can be done in the code
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Biotech and Pharmaceutical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!