dection of a word inside a condition (if)

1 次查看(过去 30 天)
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

回答(1 个)

per isakson
per isakson 2014-10-30
编辑:per isakson 2014-10-30
First idea:
>> material = 'steel';
>> strcmp( material, 'steel' )
ans =
1
  6 个评论
Image Analyst
Image Analyst 2014-10-30
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Debugging and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by