Error using title of plot

6 visualizaciones (últimos 30 días)
Meva
Meva el 6 de Abr. de 2015
Comentada: Meva el 6 de Abr. de 2015
Hi,
I want to use plot with title command. But when I try title of :
title(['Plots of ... with beta1=',num2str(beta1)','alphabar=',num2str(alphabar)]);
it gives me error saying :
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
But without
beta1=',num2str(beta1)','alphabar=',num2str(alphabar)])
it is working. So beta1 and alphabar should be indicated somewhere in figure but how?

Respuesta aceptada

Mahdiyar
Mahdiyar el 6 de Abr. de 2015
Hi Meva
Can you send the values of "beta1" and "alphabar"?
The problem is about the dimention of "beta1" or "alphabar". One of them is a column vector.
Please check the value of these two variables.
Regards,
  7 comentarios
Mahdiyar
Mahdiyar el 6 de Abr. de 2015
the point is that you put one " ' " extera. that is all.
Meva
Meva el 6 de Abr. de 2015
thank you that solved the problem.

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 6 de Abr. de 2015
That's why I prefer to use sprintf() instead of [ ].
caption = sprintf('Plots of ... with beta1=%f, alphabar=%f', beta1, alphabar);
title(caption, 'FontSize', 25);
  3 comentarios
Image Analyst
Image Analyst el 6 de Abr. de 2015
What happens if you take off the semicolon? It should definitely define it:
caption = sprintf('Plots of ... with beta1=%f, alphabar=%f', beta1, alphabar)
The only way for caption to not be defined is if it completely skipped the line. But if it skipped that line, it wouldn't have executed the title() line either. Makes no sense.
Meva
Meva el 6 de Abr. de 2015
I took off the semicolon but it says the same thing. Thanks.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by