Unable to perform assignment because the size of the left side is 588-by-3603 and the size of the right side is 588-by-719-by-3 error

4 visualizaciones (últimos 30 días)
I recieve this error in my fallowing code ;
clc
clear
rawTable = readtable('1500_3_100_1113.xlsx');
x = rawTable.Volume;
y = rawTable.P_Silindir_Basinci_A_1;
figure;
plot(x,y);
Area=AreaUnderCurve(x,y)
please help me about it
  2 comentarios
Dyuman Joshi
Dyuman Joshi el 25 de Dic. de 2023
Please share the full error message i.e. all of the red text.
In which line does the error occur?
Also, share the data you are working with so that we can reproduce the error you get and provide suggestions/solutions.
Walter Roberson
Walter Roberson el 25 de Dic. de 2023
Given that code, the error would have to be inside AreaUnderCurve, which you did not post the source for.

Iniciar sesión para comentar.

Respuestas (2)

DGM
DGM el 8 de En. de 2024
Editada: DGM el 8 de En. de 2024
The actual solution is probably to delete AreaUnderCurve() and actually pay attention to what you're doing with your data.
Why would I say that? This is why.
In order to find the area under the curve, the function plots the xy data using fill() and asterisk markers, takes an arbitrarily-scaled screenshot, reads it back off the disk, discards any color information, and then blindly thresholds the image and crops a specific region from the arbitrarily-sized thresholded image. Nothing ensures that the cropped region ever corresponds to the plot region.
The result is the average intensity of a randomly selected region in a blindly thresholded screenshot -- text, ticks, and markers included. It's a garbage number that's largely a function of the figure window geometry and the version being used. OP probably figured out that the results were nonsense and had modified the magic numbers within, resulting in an actual indexing error instead of silent garbage generation.
If it's seen that it's necessary to rasterize the curve in order to find the enclosed area, using screenshots seems like the worst possible way of doing it. I don't see why poly2mask() and bwarea() wouldn't suffice, though there's a lot about the problem that nobody knows. OP was certainly never interested in providing a description of the observed problem, let alone the overall task. I suppose the most certain answer that can be given is a lesson on basic communication.

Asim
Asim el 8 de En. de 2024
Hello Belen,
I understand you're encountering an error due to a size mismatch during an assignment in MATLAB. The left side of the assignment expects a 588-by-3603 matrix, but the right side is providing a 588-by-719-by-3 array, which is essentially a 3D array.
To resolve this error, you need to ensure that the sizes of the matrices on both sides of the assignment match. If the third dimension of the right side (with size 3) is not needed, you can either reshape the array to a 2D matrix or use the 'squeeze' function if one of the dimensions is a singleton. The documentation of the reshape function is available at the following link: https://www.mathworks.com/help/matlab/ref/reshape.html
If you need further assistance, please provide additional context or code snippets.
Best Regards,
Asim Asrar

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by