# Error when using uq\_evalStochSimMetrics with SPCE model

**URL:** <https://uqworld.org/t/error-when-using-uq-evalstochsimmetrics-with-spce-model/9081>\
**Category:** Community Q&A and How To\
**Created:** [October 12, 2025, 8:02pm UTC](https://uqworld.org/t/error-when-using-uq-evalstochsimmetrics-with-spce-model/9081 "2025-10-12T20:02:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![HZhang](https://uqworld.org/letter_avatar_proxy/v4/letter/h/df788c/32.png) [@HZhang](https://uqworld.org/u/HZhang)\
**Post date:** [October 12, 2025, 8:02pm UTC](https://uqworld.org/t/error-when-using-uq-evalstochsimmetrics-with-spce-model/9081/1 "2025-10-12T20:02:52Z")

</div>

Hi,

I am encountering the following errors when using the “uq\_evalStochSimMetrics” function to get the metrics of an SPCE model:

> Error using uq\_eval\_univ\_basis (line 46)  
> Index in position 1 exceeds array bounds. Index must not exceed 2.
> 
> Error in uq\_PCE\_eval\_unipoly (line 33)  
> univ\_p\_val = uq\_eval\_univ\_basis(U, BasisParameters);  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> Error in uq\_PCE\_eval (line 84)  
> univ\_p\_val = uq\_PCE\_eval\_unipoly(current\_model, U(:,nonConstIdx));  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> Error in uq\_eval\_uq\_metamodel (line 10)  
> [varargout{1:nargout}] = uq\_PCE\_eval(current\_model,X);  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> Error in uq\_evalModel (line 100)  
> [varargout{1:nargout}] = current\_model.eval(current\_model,varargin{:});  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> Error in uq\_SPCE\_LatentPCECoeff (line 42)  
> coefZ = uq\_evalModel(PCECoef,X)';  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> Error in uq\_SPCE\_evalModelSampleMetrics (line 139)  
> [coefZ,Zdegree] = uq\_SPCE\_LatentPCECoeff(mySPCE,X,oo);  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> Error in uq\_evalStochSimMetrics (line 6)  
> metrics = uq\_SPCE\_evalModelSampleMetrics(module,X,Y,varargin);  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> Error in evalSPCEMetrics (line 4)  
> uq\_evalStochSimMetrics(mySPCE,mySPCE.ExpDesign.X,mySPCE.ExpDesign.Y)  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I have attached my SPCE model and the script used to run the “uq\_evalStochSimMetrics” function. Any help or suggestions on how to resolve this issue would be greatly appreciated!

[evalSPCEMetrics.zip](https://uqworld.org/uploads/short-url/8TGVYy8h15wb0e0oUvHyrQQvwYR.zip) (136.9 KB)
