Failed to resolve error: 'Dot indexing is not supported for variables of this type.'
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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))
Standarddeviatiation = pdf_values2.SD;
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
Respuestas (1)
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:
- https://www.mathworks.com/help/matlab/ref/struct.html
- https://www.mathworks.com/help/matlab/matlab_prog/indexing-into-function-call-results.html
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
0 comentarios
Ver también
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!