How do I enter a string input that will later be used in a title?
1 view (last 30 days)
Show older comments
Essentially, why does the follow code not work?
data = data(:, 1:2); %Condenses matrix by removing unused columns
Savedata = data; %Saves data before manipulation.
data = data*25.4; %Converts to millimeters
data(1:11, :) = []; %Removes datum set up measurements
N = length(data(:, 1)); %Assigns to N the number of entries in column 1
%If the data is formatted incorrectly (a wrong number of rows), then this code will inform the user of this problem.
if mod(N,3) ~= 0
clc
disp('Clear variables and reload data.')
disp('There is an incorrect number of rows')
return
end
data = data(3:3:N, :); %Removes 'point' information. Now there are only distance measurements (x and y) in the matrix
dat = data;
%Inputs
diename = input('Enter the name of the die: ', 's'); %Name of die for graphical output
nom = input('Enter the nominal value for the separation distance (mm): '); %Allows the user to enter the nominal value of separation.
tol = .00254;
numstd = 5; %Number of standard deviations for outlier removal
.
.%morecode
.
postnomtable(postnomtable==0)=NaN;
figure
pcolor(postnomtable)
colormap(GColorMap); %GColorMap has already been made
colorbar;
title('Figure 2: Cell Separation Distance (mm) - Difference between Nominal and Measured for a DPF Die %s Measured on the OGP', diename)
Here's the error I'm getting:
Enter the name of the die: asdf
Enter the nominal value for the separation distance (mm): .31
Is the skin included in this measurement? n
??? Error using ==> title at 29 Incorrect number of input arguments
Error in ==> title at 23 h = title(gca,varargin{:});
Error in ==> NotRotationandSkin01 at 338 title('Figure 2: Cell Separation Distance (mm) - Difference between Nominal and Measured for a DPF Die %s Measured on the OGP', diename)
>>
0 Comments
Accepted Answer
Jan
on 19 Jul 2012
Edited: Jan
on 19 Jul 2012
The meaning of "Incorrect number of input arguments" seems to be clear: title accepts one string only.
title(sprintf(['Figure 2: Cell Separation Distance (mm) - ', ...
'Difference between Nominal and Measured for ', ...
'a DPF Die %s Measured on the OGP'], diename));
2 Comments
Jan
on 19 Jul 2012
The inputs of title are explained in doc title. There you find "title('string')". Inserting a another string at the %s key is a task for sprintf and including this into title would be an over-featuring, which would make the parsing of the other input arguments extremely complicated.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!