%% Test Sheet
%% Open data location
% find open Excel File (if multiple, chooses 'current')
DB = actxGetRunningServer('Excel.Application');
% choose correct tab
DBsheet = DB.ActiveWorkbook.Sheets;
DBsheet = DBsheet.get('Item',15);
DBsheet.Activate;
%% Import data
% Specify range and import data
range = 'L5:O14';
data = DBsheet.Range(range).Value;
% Setup transposition of data to fit table
[rows, columns] = size(data);
dataTranspose = cell(columns, rows);
% Loop to transpose one row at a time
for row = 1:rows;
% Loop columns
for col = 1:columns;
% Transpose
dataTranspose{col, row} = data{row, col};
end
end
% Conver to table and assign variable names
data = array2table(dataTranspose, 'VariableNames',{'ATAD','TDS','Depth','Standard','SF','Design',...
'Alt 1','Alt 2','Alt 3','Alt 4'});
%% find modifiers
% Determine TDS factor - This works fine
TDS = data{:,"TDS"};
for row = 1:numel(TDS);
if TDS{row} > 1000
ktds(row) = exp(9.65*10^(-5)*(2000-1000));
else
ktds = 1;
end
end
% Find standard factor - this breaks as I need to access a Depth value that
% corresponds to the row of the loop
STD = data{:,"Standard"};
for row = 1:numel(STD);
if STD{row} == 'DWA'
standard(row) = 1-2.29*10^(-4)*(data(row,"Depth")/3.2808)^2+9.19*10^(-3)*(data(row,"Depth")/3.2808);
else
standard = 1;
end
end
>> for row = 1:numel(STD); if STD{row} == 'DWA' standard(row) = 1-2.29*10^(-4)*(data(row,"Depth")/3.2808)^2+9.19*10^(-3)*(data(row,"Depth")/3.2808); else standard = 1; end end Error using / Arguments must be numeric, char, or logical.
Is there a way to access these numerical values within the formula? I've tried dot indexing Value like in my previous code, but that receives an error as well. Do I need to use another nested loop? I'm still fairly inexperienced and have trouble diagnosing these problems.
I found a solution to my problem that looks to be the simplest. I used the cell2mat function in conjunction with the table indexing. See the following code,
for row = 1:numel(STD); if STD{row} == 'DWA' standard(row) = 1-2.29e-4*(cell2mat(data{row,'Depth'})/3.2808)^2+9.19e-3*(cell2mat(data{row,'Depth'})/3.2808); else standard = 1; end end
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.