dection of a word inside a condition (if)

조회 수: 3 (최근 30일)
Josep
Josep 2014년 10월 30일
댓글: Image Analyst 2014년 10월 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
Josep
Josep 2014년 10월 30일
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에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by