Failed to resolve error: 'Dot indexing is not supported for variables of this type.'

2 visualizaciones (últimos 30 días)
I want to find various statistics for my data using CUPID. I am following instructions from Cupid.pdf documentation. Here is the code for obtaining standard deviation. I have attached the data. I have read some solutions to similar errors but have yet to relate them to my problem.
clc; close all; clear;
SpeedM = readmatrix("SpeedM.xlsx");
% addpath('C:\Users\user\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Cupid');
x2 = linspace(0, max(SpeedM) + 1, 100); % Values for which to compute PDF
custpdf = @(x2,a,b,c) (x2>c).*(b/a).*(((x2-c)/a).^(b-1)).*exp(-((x2-c)/a).^b);
opt = statset('MaxIter',1e5,'MaxFunEvals',1e5,'FunValCheck','off');
phat = mle(SpeedM,'pdf',custpdf,'start',[0 0 0],'Options',opt,...
'LowerBound',[0 0 -Inf],'UpperBound',[Inf Inf min(SpeedM)]);
pdf_values2 = custpdf(x2,phat(1),phat(2),phat(3))
pdf_values2 = 1×100
0 0.0214 0.0563 0.0861 0.1126 0.1361 0.1568 0.1745 0.1895 0.2017 0.2112 0.2181 0.2225 0.2245 0.2244 0.2223 0.2184 0.2129 0.2061 0.1982 0.1893 0.1797 0.1696 0.1591 0.1484 0.1377 0.1272 0.1168 0.1067 0.0970
Standarddeviatiation = pdf_values2.SD;
Dot indexing is not supported for variables of this type.
However, I am getting an error:
"Dot indexing is not supported for variables of this type."
I have followed links suggested here but failed to resolve the error. Please assist.
  1 comentario
Matt J
Matt J el 9 de Oct. de 2023
Editada: Matt J el 9 de Oct. de 2023
Look at the output of your code above. pdf_values2 is a 1x100 numeric vector, not a struct.

Iniciar sesión para comentar.

Respuestas (1)

Sai Pavan
Sai Pavan el 16 de Oct. de 2023
Hi Chish,
I understand that you are trying to resolve the dot indexing error and calculate the standard deviation of the “pdf_values2” variable.
You are encountering the dot indexing error because you are trying to access the SD property of an array pdf_values2, which does not have such a property. The pdf_values2 variable is a 1x100 array of probability density values, not a structure with a SD property.
Please refer to the below documentation to learn how to use dot indexing:
Alternatively, you may try the std function to calculate the standard deviation. Please refer to the below code snippet to calculate the standard deviation of the “pdf_values2” array:
Standarddeviation = std(pdf_values2);
Please refer the below documentation to learn more about the “std” function:https://www.mathworks.com/help/matlab/ref/std.html
Hope it helps.
Regards,
Sai Pavan

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by