"Claudia Champagne"
> How can I enter string inputs into a function within a loop?
>
> I want to use the function [d,A]=strdist(r,b,krk,cas) in a loop since I have a number of r and b inputs for which I need the distance.
>
> The problem is that inputs r and b have to appear in a string form for the function to work:
> e.g. strdist('MATLAB','MathWorks',2,1)
> ans = 6 9
>
> However, if these 2 strings ('Matlab' and 'Mathworks') are located in arrays, the function does not work properly as it doesn't read them as strings.
>
> For example:
> r_array = cell array of r (where 'Matlab' is located)
> b_array = cell array of b (where 'MathWorks' is located)
>
> I tried the following :
>
> [d,A] = strdist(cellstr(r_array{1,1}), cellstr(b_array{1,1}),2,1)
>
> and I get an answer if 1, which is the answer that I get when I enter just about anything as input.
>
> How can I tell the function to read my inputs as strings?
In1 = {'Hi','Hello'};
In2 = {'Bye','GoodBye'};
nIter = numel(In1);
if nIter == numel(In2)
Out = cell(nIter,2);
for n = 1:numel(In1)
[Out{nIter,1}, Out{nIter,1}] = strdist(In1{nITer},In2{nITer},2,1);
end
Oleg
