dection of a word inside a condition (if)
古いコメントを表示
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
2014 年 10 月 30 日
編集済み: per isakson
2014 年 10 月 30 日
First idea:
>> material = 'steel';
>> strcmp( material, 'steel' )
ans =
1
6 件のコメント
Josep
2014 年 10 月 30 日
Image Analyst
2014 年 10 月 30 日
if strcmp(material, 'steel') && Sut>0.4 && Sut<=0.7
and so on.
Josep
2014 年 10 月 30 日
編集済み: per isakson
2014 年 10 月 30 日
per isakson
2014 年 10 月 30 日
"an error message"   What does it say and which line causes the error?
Josep
2014 年 10 月 30 日
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.
カテゴリ
ヘルプ センター および File Exchange で Printing and Saving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
