dection of a word inside a condition (if)
Mostrar comentarios más antiguos
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
Respuestas (1)
per isakson
el 30 de Oct. de 2014
Editada: per isakson
el 30 de Oct. de 2014
First idea:
>> material = 'steel';
>> strcmp( material, 'steel' )
ans =
1
6 comentarios
Josep
el 30 de Oct. de 2014
Image Analyst
el 30 de Oct. de 2014
if strcmp(material, 'steel') && Sut>0.4 && Sut<=0.7
and so on.
Josep
el 30 de Oct. de 2014
Editada: per isakson
el 30 de Oct. de 2014
per isakson
el 30 de Oct. de 2014
"an error message"   What does it say and which line causes the error?
Josep
el 30 de Oct. de 2014
Image Analyst
el 30 de Oct. de 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.
Categorías
Más información sobre Printing and Saving en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
