Dot indexing is not supported for variables of this type.
Show older comments
please someone help me with this as soon as possible as i have a submission due.
I am new to Matlab,and i dont know why this error pops up in mycod.This code is same to all other students and they are able to run it and i am not.
1)L2_1D_P3 file (which i run )
clear;format long;
%Computational domain
Lx=1;
%Local variables
XSeed= 11;
%Diffusity function
diffusivity_function=struct('type','scalar','d',1.0);
%Volumeteric Source
load_type=struct('case','homogeneous','value',1.0);
%Standard data
dim=1;dofs_per_node=1;
EleType='L2';
NGPTS=3;
%Nele and NumNodes
Nele= XSeed-1;
NumNodes=XSeed;
%Coordinate matrix
Coord=zeros(NumNodes,dim);
for row =1:XSeed
Coord(row)=Lx*(row-1)/(XSeed-1);
end
%Connectivity matrix
Connectivity=zeros(Nele,2);
for ele = 1:Nele
Connectivity(ele,:)=[ele,ele+1];
end
%Constraints matrix
Constraints=[1,1,0];
NCons= size(Constraints,1);
%Call the driver to run simulation
[U] = Driver_Steady_Diffusion(Connectivity,Constraints,...
Coord,dim,dofs_per_node,diffusivity_function,EleType,load_type,NCons,...
Nele,NGPTS,NumNodes);
%Colorful plots
plot(Coord,U,'k*','MarkerSize',20);hold on;
plot(Coord,Coord.*(Lx-Coord/2),'b-','LineWidth',2);
Legend('Numerical','Analytical','FontSize',20);
xlabel('x','FontSize',20);
ylabel('c(x)','FontSize',20);
2) Get_Volumetric source(where the error is)
function [f]= Get_VolumetricSource(load_type,x)
if strcmpi(load_type.case,'homogeneous')
f=load_type.value;
return;
end
my error message: when i run for L2_1D_P3 file
L2_1D_P3
__________________________________________
Diffusion Simulation Status Report
__________________________________________
Step1:Create GlobalId Vector
Step2:Create constraints vector
Step3: Calculate global stiffness matrix and load vector;
Dot indexing is not supported for variables of this type.
Error in Get_VolumetricSource (line 5)
if strcmpi(load_type.case,'homogeneous')
Error in CalculateLocalMatrices (line 34)
rlocal=rlocal+w(gpt)*N'*Get_VolumetricSource(load_type,x)*detJ;
Error in CalculateGlobalMatrices (line 30)
[klocal,rlocal]=CalculateLocalMatrices(diffusivity_function,EleNodes,EleType,...
Error in Driver_Steady_Diffusion (line 36)
[K_FF,K_FP,R_F]=CalculateGlobalMatrices(Connectivity,...
Error in L2_1D_P3 (line 39)
[U] = Driver_Steady_Diffusion(Connectivity,Constraints,...
8 Comments
Rik
on 4 May 2020
How is the Get_VolumetricSource function called? What are the input arguments?
Kiran Patil
on 4 May 2020
Kiran Patil
on 4 May 2020
Rik
on 4 May 2020
Apparently not. What is the exact syntax you are using to call Get_VolumetricSource?
________
_____=Get_VolumetricSource(_______)
Rik
on 4 May 2020
You really need to learn debugging. Put a breakpoint on the first line of L2_1D_P1, run it and then run your code step by step. Then you can step in and out of functions to explore where your variables don't match your expectations anymore.
I doubt someone will go to trouble of downloading dozens of files. Try to make a MWE so we can run your code without any other dependencies and can reproduce your issue.
Kiran Patil
on 4 May 2020
Kiran Patil
on 4 May 2020
Kiran Patil
on 4 May 2020
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!