Keeps skipping my input query

12 views (last 30 days)
Jeremy Taylor Miller
Jeremy Taylor Miller on 30 Oct 2020
MATLAB keeps skipping my query for an input only for the 3rd and 4th input I'm asking for... Not sure why. Any help? It skips directly after BM_str input down to the answer = inputdlg.
BW_str = input('Select water blank wells.\n', 's');
BW = str2num(BW_str);
BWa = mean(BW);
BM_str = input('Select media blank wells.\n', 's');
BM = str2num(BM_str);
BMa = mean(BM);
%Subtract blank from standards
SW_str = input('Input water standard to subtract blank.\n', 's');
SW = str2num(SW_str);
SW2 = SW-BWa;
SM_str = input('Input media standard to subtract blank.\n', 's');
SM = str2num(SM_str);
SM2 = SM-BMa;
SM2 = SM2';
%Select X values
prompt = {'Enter X values','Enter units'};
dlgtitle = 'X-axis values';
dims = [1 35];
definput = {'[40 20 10 5 2.5 1.25 0.625]','[RNA] (ng)'};
answer = inputdlg(prompt,dlgtitle,dims,definput);
  5 Comments
Jeremy Taylor Miller
Jeremy Taylor Miller on 3 Nov 2020
So I isolated the problem. I've pasted the whole code below for context. Basically, it's a program where I build a linear fit based off a standard curve from some data output. I subtract the blanks out, select my standard curves, and then input my experimental values. The program automatically outputs the standard curves and the resulting experimental output. The math works, only when I tried to mess with the input command did I run into problems.
%% Quick calculator for standard curves from excel %%
%% Import file
[file,path] = uigetfile('*.xlsx');
if isequal(file,0)
disp('User selected Cancel');
else
disp(['User selected ', fullfile(path,file)]);
end
%Import standard curve values
uiimport(file)
%% Build standard curves
%Select blank cells for the first standard
BW_str = input('Select water blank wells.\n', 's');
BW = str2num(BW_str);
BWa = mean(BW);
BM_str = input('Select media blank wells.\n', 's');
BM = str2num(BM_str);
BMa = mean(BM);
%Subtract blank from standards
SW_str = input('Input water standard to subtract blank.\n', 's');
SW = str2num(SW_str);
SW2 = SW-BWa;
SM_str = input('Input media standard to subtract blank.\n', 's');
SM = str2num(SM_str);
SM2 = SM-BMa;
SM2 = SM2';
%Select X values
prompt = {'Enter X values','Enter units'};
dlgtitle = 'X-axis values';
dims = [1 35];
definput = {'[40 20 10 5 2.5 1.25 0.625]','[RNA] (ng)'};
answer = inputdlg(prompt,dlgtitle,dims,definput);
X = str2num(answer{1});
XW = kron(X,ones(1,3)); %expands X axis to match matrix size of SW2
XM = XW';
XW = XW';
SW3 = SW2';
SW4 = SW3(:);
SM3 = SM2';
SM4 = SM3(:); %this is to convert matrices to single columns that match the number of X values
%Build standard curves
figure(1)
scatter(XW,SW4);
PW = polyfit(XW,SW4,1);
yfit = PW(1)*XW+PW(2);
hold on
plot(XW,yfit,'k-.');
scatter(XM,SM4);
PM = polyfit(XM,SM4,1);
yfit2 = PM(1)*XM+PM(2);
plot(XM,yfit2,'k-.');
xlabel(answer{2});
ylabel('RFU');
Water_Standard = fitlm(XW,SW4) %outputs coefficients for linear fit & R2 value
Media_Standard = fitlm(XM,SM4)
%% Run experimental data through standard curve
Wx = PW(1); %slope from water fit
Wy = PW(2); %y-intercept from water fit
Mx = PM(1);
My = PM(2);
WI_str = input('Input water experimental values.\n', 's');
WI = str2num(WI_str)-BWa;
MI_str = input('Input media experimental values.\n', 's');
MI = str2num(MI_str)-BMa;
WF = (WI-Wy)/Wx
MF = (MI-My)/Mx
The way the program works, I open my excel file using uiiimport and would copy over my matrix values into MATLAB from there. While the import window was up, MATLAB would skip the inputs as described. What is odd is that this was only an issue when usin the 's' output parameter for input. Without the 's', there is no issue with this. I think I will try optimizing this to automatically import the experimental data and work with that matrix, instead of manually copying over values myself.
If you have any suggestions for easier ways to input and work with excel data I'd love to hear them.
Thanks for your input, I was able to determine it was something specific to the way I was copying over excel data.
Jeremy Taylor Miller
Jeremy Taylor Miller on 3 Nov 2020
All I really want is a way to manually open an excel sheet and select what data from that sheet I want to import. From there I can figure out the rest. I think I'll try messing around with readtable, readmatrix, and uiimport and see if I can get something to work.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!