dection of a word inside a condition (if)

1 view (last 30 days)
Josep
Josep on 30 Oct 2014
Commented: Image Analyst on 30 Oct 2014
I have programmed a code and I would like Matlab to recognise the word of materials (steel and aluminium). Any idea?
Following I put the code:
function y=kfgraf(r,Sut,material)
a=xlsread('kf.xls'); %Extret del webplotdigitizer
x1=a(1:67,1);
y1=a(1:67,2);
x2=a(1:65,3);
y2=a(1:65,4);
x3=a(1:64,5);
y3=a(1:64,6);
x4=a(1:63,7);
y4=a(1:63,8);
x5=a(1:59,9);
y5=a(1:59,10);
if material==steel && Sut<=0.4
i1=interp1(x1,y1,r,'spline');
y=i1
end
if material==steel && Sut>0.4 && Sut<=0.7
i1=interp1(x1,y1,r,'spline');
i2=interp1(x2,y2,r,'spline');
prop=((Sut-0.4)/(0.7-0.4))
y=i1+prop.*(i2-i1);
end
if material==steel && Sut>0.7 && Sut<=1
i1=interp1(x2,y2,r,'spline');
i2=interp1(x3,y3,r,'spline');
prop=((Sut-0.7)/(1-0.7))
y=i1+prop.*(i2-i1);
end
if material==steel && Sut>1 && Sut<=1.4
i1=interp1(x3,y3,r,'spline');
i2=interp1(x4,y4,r,'spline');
prop=((Sut-1)/(1.4-1))
y=i1+prop.*(i2-i1);
end
if material==steel && Sut>=1.4
i1=interp1(x4,y4,r,'spline');
y=i1
end
if material==aluminium
i1=interp1(x5,y5,r,'spline');
y=i1
end
end

Answers (1)

per isakson
per isakson on 30 Oct 2014
Edited: per isakson on 30 Oct 2014
First idea:
>> material = 'steel';
>> strcmp( material, 'steel' )
ans =
1
  6 Comments
Image Analyst
Image Analyst on 30 Oct 2014
How are you calling this function? It requires input arguments so you can't just click the green triangle to run it. What the warning (not error) is saying is that you accept material via the input argument list but you don't use it because you overwrite it immediately with the line
material='steel';
so whatever you pass in is ignored completely, so you might as well not bother having it or passing it in.

Sign in to comment.

Categories

Find more on Debugging and Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!