I am trying to test a part of my code but it shows me this message ! how can i solve it , Help plz !

조회 수: 2 (최근 30일)
I am trying to test a part of my code but it shows me this message ! how can i solve it , Help plz !
Cannot find an exact (case-sensitive) match for 'Material'
The closest match is: material in D:\toolbox\matlab\graph3d\material.m
  댓글 수: 2
Jorg Woehl
Jorg Woehl 2021년 3월 5일
Are you trying to execute code that you have saved to a file called Material.m?
If that's the case, make sure to first navigate to the folder containing Material.m before calling Material from the command line.
Sura Hatem Basir Al-Ani
Sura Hatem Basir Al-Ani 2021년 3월 5일
%Initialisation---------------------------------------
clc;clear;format short g;format compact;
%-------------------------------------------------
%file name: Mat_Data
%thickness and cost factor
%INPUTS-1: search parameters
material(1).Sy=170; material(1).t=[2,4,6,8,10,20,30]; material(1).CF=1.00;
material(2).Sy=280; material(2).t=[1,2,3,4,6,8,10,12,14,16,18,20]; material(2).CF=1.37;
material(3).Sy=180; material(3).t=[2,4,6,8,10,20]; material(3).CF=0.88;
material(4).Sy=300; material(4).t=[2,4,6,8,10,20]; material(4).CF=1.47;
material(5).Sy=190; material(5).t=[2,4,6,8,10,20]; material(5).CF=0.93;
material(6).Sy=320; material(6).t=[2,4,6,8,10,20]; material(6).CF=1.57;
material(7).Sy=220; material(7).t=[2,4,6,8,10,20]; material(7).CF=1.08;
material(8).Sy=370; material(8).t=[1,2,3,4,6,7,8,9,10,12,14,16]; material(8).CF=1.81;
material(9).Sy=210; material(9).t=[2,4,6,8,10,14,16,20,30,40]; material(9).CF=1.03;
material(10).Sy=390; material(10).t=[1,2,3,4,6,8,10,12,14,16,18,20]; material(10).CF=1.91;
material(11).Sy=260; material(11).t=[ 2,4,6,8,10,12,16,20,30,40,50]; material(11).CF=1.27;
material(12).Sy=440; material(12).t=[2,4,6,8,10]; material(12).CF=2.16;
material(13).Sy=270; material(13).t=[1,2,3,4,5,6,7,8,9,10]; material(13).CF=1.32;
material(14).Sy=460; material(14).t=[1,2,3,4,5,6,7,8,9,10]; material(14).CF=2.25;
material(15).Sy=290; material(15).t=[2,4,6,8,10,12,18,20,30]; material(15).CF=1.42;
material(16).Sy=490; material(16).t=[1,2,3,4,5,6,7,8,9,10]; material(16).CF=2.40;
material(17).Sy=310; material(17).t=[1,2,3,4,5,6,7,8,9,10]; material(17).CF=1.52;
material(18).Sy=530; material(18).t=[10,20,30]; material(18).CF=2.60;
material(19).Sy=340; material(19).t=[4,5,8,14,20]; material(19).CF=1.67;
material(20).Sy=580; material(20).t=[2,4,6,8,10]; material(20).CF=2.84;
material(21).Sy=370; material(21).t=[2,4,6,8,10,15,18,20]; material(21).CF=1.81;
material(22).Sy=420; material(22).t=[2,4,6,8,10,12,14]; material(22).CF=2.06;
material(23).Sy=460; material(23).t=[1,2,4,6,8,10,12];
save ('Materials_table.mat', 'material')
%INPUTS-2: Physical inputs
P_bar=str2double(get(findobj('tag','Pressure'),'string')); %Internal Pressure of pressure vessel (Bar)
C=str2double(get(findobj('tag','Capacity'),'string')); %Capacity (Litres)
n_d=str2double(get(findobj('tag','Safety Factor'),'string')); %safety factor
L_t=str2double(get(findobj('tag','Length Constraint'),'string')); %length of pressure vessel (m)
H=str2double(get(findobj('tag','Height Constraint'),'string')); %Height of pressure vessel (m)
step=str2double(get(findobj('tag','step'),'string')); %step for loop
%conversion
P=P_bar*10^5; %conversion of Mpa to Pa
C=C*10^-3; %conversion of litres to m^3
%------------------------------------------------------------------------------------
%Errors
sol=[];
if P_bar <= 0
set(findobj('tag','errors'),'string','Un valid value of internal pressure')
clc
return
elseif isempty (P_bar) == true
set(findobj('tag','errors'),'string','Un valid value of internal pressure')
clc
return
end
if L_t <= 0
set(findobj('tag','errors'),'string','Un valid value of the lenght')
elseif isempty (L_t) == true
set(findobj('tag','errors'),'string','Un valid value of the lenght')
clc
return
end
if n_d <= 0
set(findobj('tag','errors'),'string','Un valid value of safety factor')
elseif isempty (n_d) == true
set(findobj('tag','errors'),'string','Un valid value of safety factor')
clc
return
end
if C <= 0
set(findobj('tag','errors'),'string','Un valid value of the capacity')
elseif isempty (C) == true
set(findobj('tag','errors'),'string','Un valid value of the capacity')
clc
return
end
if H <= 0
set(findobj('tag','errors'),'string','Un valid value of the height')
elseif isempty (H) == true
set(findobj('tag','errors'),'string','Un valid value of the height')
clc
return
end
if step <= 0
set(findobj('tag','errors'),'string','Un valid value of the step radius')
elseif isempty (step) == true
set(findobj('tag','errors'),'string','Un valid value of the step radius')
clc
return
elseif isempty (step) > 1
set(findobj('tag','errors'),'string','Un valid value of the step radius')
clc
return
end
%Calculations
for k=1:1:lenght(Material)
CF=material(k).CF;
S_y=material(k).S_y*10e6;
allow_stress=S_y/n_d;
end
for x=1:3:lenght(material(x).t)
t=material(x).t(x)/1000;
z=H/2-t;
end
for r_i=0:step:z
r_o=r_i+t;
L_t=L+2*r_o;
end
if t/r_i >= 0.05
stress_t=((ri^2*P)/(ro^2-ri^2))*(1+(ro^2/ri^2));
stress_r=((ri^2*P)/(ro^2-ri^2))*(1-(ro^2/ri^2));
stress_l=((ri^2*P)/(ro^2-ri^2));
type=thick;
else
stress_t=P*ri/t;
stress_r=0;
stress_l=P*ri/(2*t);
type=thin;
end
stress_VM= sqrt(((stress_t-stress_r)^2+(stress_t-stress_l)^2+(stress_l-stress_r)^2)/2);
if stress_VM <= allow_stress && L>0
V_mat= 2*pi*r_i*t*L+4*pi*r_i^2*t;
CI=V_mat*CF;
stress_alldisp=stress_all/10e6;
stress_VMdisp=stress_VM/10e6;
L_tDisp=L+2*ro;
Hdisp=2*ro;
sol=[sol;r_i,r_o,t,stress_alldisp,stress_VMdisp,V_mat,CI,L_tDisp,Hdisp,type];
end
sol_sorted=sortrows(sol,8);
opt_sol=sol_sorted(1,:);
%outputs
set(findobj('tag','Inner radius'),'string', (sol_sorted(1,1)))
set(findobj('tag','Material number'),'string', (sol_sorted(1,2)))
set(findobj('tag','Thickness'),'string', (sol_sorted(1,3)))
set(findobj('tag','Total lenght'),'string', (sol_sorted(1,4)))
set(findobj('tag','Allowable Stress'),'string', (sol_sorted(1,5)))
set(findobj('tag','Von Mises Stress'),'string', (sol_sorted(1,6)))
set(findobj('tag','Vessel material volume'),'string', (sol_sorted(1,7)))
set(findobj('tag','Vessel Cost Index'),'string', (sol_sorted(1,8)))
set(findobj('tag','Height'),'string', (sol_sorted(1,9)))
set(findobj('tag','Outer radius'),'string', (sol_sorted(1,10)))
set(findobj('tag','Thickness type'),'string', (sol_sorted(1,11)))
this is my code

댓글을 달려면 로그인하십시오.

답변 (2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 3월 5일
편집: KALYAN ACHARJYA 2021년 3월 5일
This is due to a name mismatch between the upper case or lower case in the custom function name. Matlab is case-sensitive. Modify either in the function name or the main script.
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 3월 5일
... or it could mean that you really did mean Material with a capital but that there is no function named Material in the MATLAB path.
... or it could mean that you were use a matrix named Material but that matrix is not defined at that point in the code.
Sura Hatem Basir Al-Ani
Sura Hatem Basir Al-Ani 2021년 3월 5일
%Initialisation---------------------------------------
clc;clear;format short g;format compact;
%-------------------------------------------------
%file name: Mat_Data
%thickness and cost factor
%INPUTS-1: search parameters
material(1).Sy=170; material(1).t=[2,4,6,8,10,20,30]; material(1).CF=1.00;
material(2).Sy=280; material(2).t=[1,2,3,4,6,8,10,12,14,16,18,20]; material(2).CF=1.37;
material(3).Sy=180; material(3).t=[2,4,6,8,10,20]; material(3).CF=0.88;
material(4).Sy=300; material(4).t=[2,4,6,8,10,20]; material(4).CF=1.47;
material(5).Sy=190; material(5).t=[2,4,6,8,10,20]; material(5).CF=0.93;
material(6).Sy=320; material(6).t=[2,4,6,8,10,20]; material(6).CF=1.57;
material(7).Sy=220; material(7).t=[2,4,6,8,10,20]; material(7).CF=1.08;
material(8).Sy=370; material(8).t=[1,2,3,4,6,7,8,9,10,12,14,16]; material(8).CF=1.81;
material(9).Sy=210; material(9).t=[2,4,6,8,10,14,16,20,30,40]; material(9).CF=1.03;
material(10).Sy=390; material(10).t=[1,2,3,4,6,8,10,12,14,16,18,20]; material(10).CF=1.91;
material(11).Sy=260; material(11).t=[ 2,4,6,8,10,12,16,20,30,40,50]; material(11).CF=1.27;
material(12).Sy=440; material(12).t=[2,4,6,8,10]; material(12).CF=2.16;
material(13).Sy=270; material(13).t=[1,2,3,4,5,6,7,8,9,10]; material(13).CF=1.32;
material(14).Sy=460; material(14).t=[1,2,3,4,5,6,7,8,9,10]; material(14).CF=2.25;
material(15).Sy=290; material(15).t=[2,4,6,8,10,12,18,20,30]; material(15).CF=1.42;
material(16).Sy=490; material(16).t=[1,2,3,4,5,6,7,8,9,10]; material(16).CF=2.40;
material(17).Sy=310; material(17).t=[1,2,3,4,5,6,7,8,9,10]; material(17).CF=1.52;
material(18).Sy=530; material(18).t=[10,20,30]; material(18).CF=2.60;
material(19).Sy=340; material(19).t=[4,5,8,14,20]; material(19).CF=1.67;
material(20).Sy=580; material(20).t=[2,4,6,8,10]; material(20).CF=2.84;
material(21).Sy=370; material(21).t=[2,4,6,8,10,15,18,20]; material(21).CF=1.81;
material(22).Sy=420; material(22).t=[2,4,6,8,10,12,14]; material(22).CF=2.06;
material(23).Sy=460; material(23).t=[1,2,4,6,8,10,12];
save ('Materials_table.mat', 'material')
%INPUTS-2: Physical inputs
P_bar=str2double(get(findobj('tag','Pressure'),'string')); %Internal Pressure of pressure vessel (Bar)
C=str2double(get(findobj('tag','Capacity'),'string')); %Capacity (Litres)
n_d=str2double(get(findobj('tag','Safety Factor'),'string')); %safety factor
L_t=str2double(get(findobj('tag','Length Constraint'),'string')); %length of pressure vessel (m)
H=str2double(get(findobj('tag','Height Constraint'),'string')); %Height of pressure vessel (m)
step=str2double(get(findobj('tag','step'),'string')); %step for loop
%conversion
P=P_bar*10^5; %conversion of Mpa to Pa
C=C*10^-3; %conversion of litres to m^3
%------------------------------------------------------------------------------------
%Errors
sol=[];
if P_bar <= 0
set(findobj('tag','errors'),'string','Un valid value of internal pressure')
clc
return
elseif isempty (P_bar) == true
set(findobj('tag','errors'),'string','Un valid value of internal pressure')
clc
return
end
if L_t <= 0
set(findobj('tag','errors'),'string','Un valid value of the lenght')
elseif isempty (L_t) == true
set(findobj('tag','errors'),'string','Un valid value of the lenght')
clc
return
end
if n_d <= 0
set(findobj('tag','errors'),'string','Un valid value of safety factor')
elseif isempty (n_d) == true
set(findobj('tag','errors'),'string','Un valid value of safety factor')
clc
return
end
if C <= 0
set(findobj('tag','errors'),'string','Un valid value of the capacity')
elseif isempty (C) == true
set(findobj('tag','errors'),'string','Un valid value of the capacity')
clc
return
end
if H <= 0
set(findobj('tag','errors'),'string','Un valid value of the height')
elseif isempty (H) == true
set(findobj('tag','errors'),'string','Un valid value of the height')
clc
return
end
if step <= 0
set(findobj('tag','errors'),'string','Un valid value of the step radius')
elseif isempty (step) == true
set(findobj('tag','errors'),'string','Un valid value of the step radius')
clc
return
elseif isempty (step) > 1
set(findobj('tag','errors'),'string','Un valid value of the step radius')
clc
return
end
%Calculations
for k=1:1:lenght(Material)
CF=material(k).CF;
S_y=material(k).S_y*10e6;
allow_stress=S_y/n_d;
end
for x=1:3:lenght(material(x).t)
t=material(x).t(x)/1000;
z=H/2-t;
end
for r_i=0:step:z
r_o=r_i+t;
L_t=L+2*r_o;
end
if t/r_i >= 0.05
stress_t=((ri^2*P)/(ro^2-ri^2))*(1+(ro^2/ri^2));
stress_r=((ri^2*P)/(ro^2-ri^2))*(1-(ro^2/ri^2));
stress_l=((ri^2*P)/(ro^2-ri^2));
type=thick;
else
stress_t=P*ri/t;
stress_r=0;
stress_l=P*ri/(2*t);
type=thin;
end
stress_VM= sqrt(((stress_t-stress_r)^2+(stress_t-stress_l)^2+(stress_l-stress_r)^2)/2);
if stress_VM <= allow_stress && L>0
V_mat= 2*pi*r_i*t*L+4*pi*r_i^2*t;
CI=V_mat*CF;
stress_alldisp=stress_all/10e6;
stress_VMdisp=stress_VM/10e6;
L_tDisp=L+2*ro;
Hdisp=2*ro;
sol=[sol;r_i,r_o,t,stress_alldisp,stress_VMdisp,V_mat,CI,L_tDisp,Hdisp,type];
end
sol_sorted=sortrows(sol,8);
opt_sol=sol_sorted(1,:);
%outputs
set(findobj('tag','Inner radius'),'string', (sol_sorted(1,1)))
set(findobj('tag','Material number'),'string', (sol_sorted(1,2)))
set(findobj('tag','Thickness'),'string', (sol_sorted(1,3)))
set(findobj('tag','Total lenght'),'string', (sol_sorted(1,4)))
set(findobj('tag','Allowable Stress'),'string', (sol_sorted(1,5)))
set(findobj('tag','Von Mises Stress'),'string', (sol_sorted(1,6)))
set(findobj('tag','Vessel material volume'),'string', (sol_sorted(1,7)))
set(findobj('tag','Vessel Cost Index'),'string', (sol_sorted(1,8)))
set(findobj('tag','Height'),'string', (sol_sorted(1,9)))
set(findobj('tag','Outer radius'),'string', (sol_sorted(1,10)))
set(findobj('tag','Thickness type'),'string', (sol_sorted(1,11)))
this is my code

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2021년 3월 5일
for k=1:1:lenght(Material)
You have not defined any variable named Material but you have defined a variable named material . As you are looping over the number of elements of something and inside that loop you access material() indexed by the loop variable, it would be most natural to take the length of material rather than of whatever Material is.
CF=material(k).CF;
S_y=material(k).S_y*10e6;
allow_stress=S_y/n_d;
end
for x=1:3:lenght(material(x).t)
t=material(x).t(x)/1000;
z=H/2-t;
end
Please also pay attention to the fact that in both of those for loops you use a function named lenght when you probably intended length -- ht compared to th
  댓글 수: 3
Rik
Rik 2021년 3월 5일
That means that you are trying to get the 8th element from a list that is 7 elements long.
Walter Roberson
Walter Roberson 2021년 3월 5일
for nux=1:3:lenght(material(x).t)
t=material(x).t(x)/1000;
z=H/2-t;
end
You are taking whatever value if x is left over in memory and using it to index the material structure, and you find the length of the t field there. You use that length as the upper limit in a for x loop. You then use that to index the material structure and pull out the t field and then you use the same index to index the t vector. This is sort of like going down the diagonal
For example if the value of x in memory happened to be 2 then you would have taken length of material(2).t which is 12. You would then be doing for x = 1:3:12. You would access materials(1).t(1) then materials(4).t(4) then materials(7).t(7) but that would fail because materials(7).t is only 6 elements long.
Note also that when you succeed in indexing the t vector that you calculate z. However you do not save the value and it will be overwritten by the next for x iteration.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by