How can I eliminate the following error?

33 visualizaciones (últimos 30 días)
Adrian
Adrian el 7 de Mayo de 2014
Respondida: Charitha Yampati el 24 de Mzo. de 2017
I am trying to read multiple images in order to generate a movie in Matlab. So, I use this code:
M = zeros(1,10);
for i = 1:10
images = sprintf('img%d.jpg',i);
ImageData = imread(images);
M(i) = im2frame(ImageData);
end
movie(M)
movie2avi(M,'sonar.avi','compression','None','fps',6,'quality',100)
But I get the following error:
"The following error occurred converting from struct to double:
Error using double
Conversion to double from struct is not possible.
Error in open83B_edited_2 (line 295)
M(i) = im2frame(ImageData);"
Could you please help me in seeing where is the error in my code? Thank you.

Respuesta aceptada

Justin
Justin el 7 de Mayo de 2014
The problem comes in when you are defining your M as an array of doubles before the loop. I would make sure there exists no M in the workspace or use
clear M
in place of the current M = zeros(1,10);.
The im2frame function passes a structure so M needs to be an array of structures and not doubles.

Más respuestas (3)

Astha Ameta
Astha Ameta el 13 de En. de 2017
Editada: Stephen23 el 13 de En. de 2017
Below is the code snippet for svmtrain.m :
if plotflag
hSV = svmplotsvs(hAxis,hLines,groupString,svm_struct);
svm_struct.FigureHandles = {hAxis,hLines,hSV};
end
here, plotflag is false and following error occurs: The following error occurred converting from struct to double:
Error using double
Conversion to double from struct is not possible.
I tried to make plotflag=true but still same error occurs.
Please advise.
  1 comentario
Stephen23
Stephen23 el 13 de En. de 2017
Editada: Stephen23 el 13 de En. de 2017
@Astha Ameta: If plotflag is false then the code you have shown us does not get executed, and so cannot be the cause of this error. If you want help, you should show us the code where the error happens, not some different code.
Also please show us the complete error message. This means all of the red text.

Iniciar sesión para comentar.


Gourab Nandy
Gourab Nandy el 15 de Mzo. de 2017
How can I remove this error?
close all;
figure(1);
subplot(211);
plot(t,qd(:,1),'k',t,q(:,1),'r:','linewidth',2);
xlabel('time(s)');ylabel('Position tracking of link 1');
legend('Ideal position signal','Tracking position signal');
subplot(212);
plot(t,qd(:,2),'k',t,q(:,2),'r:','linewidth',2);
xlabel('time(s)');ylabel('Speed tracking of link 1');
legend('Ideal speed signal','Tracking speed signal');
??? Error using ==> plot
Conversion to double from struct is not possible.

Charitha Yampati
Charitha Yampati el 24 de Mzo. de 2017
How to eliminate the error while converting time series to double

Categorías

Más información sobre Convert Image Type 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