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?

 採用された回答

Mahdiyar
Mahdiyar 2015 年 4 月 6 日

1 投票

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 件のコメント

Meva
Meva 2015 年 4 月 6 日
編集済み: Meva 2015 年 4 月 6 日
Hi Mahdiyar,
Thanks, these are just numbers.
alpha = 0.1;
beta1 = radtodeg(pi)*alpha;
alphabar = 1;
Meva
Meva 2015 年 4 月 6 日
and If I try without beta1 in title
(let us say the trouble comes from radtodeg) it is still giving the same error.
Actually I have been facing to this problem
when I include the num2str in the title line for a while.
Mahdiyar
Mahdiyar 2015 年 4 月 6 日
Hi
you just did one little mistake. follow the code below. I tried and it works
alpha = 0.1;
beta1 = radtodeg(pi)*alpha;
alphabar = 1;
plot(1:10,1:10)
title(['Plots of ... with beta1=',num2str(beta1),'alphabar=',num2str(alphabar)]);
The problem is that the size of num2str(beta1) is 1*1 and it is counted as row vector but num2str(beta1)' is also 1*1 but it is counted as column vector.
Regards
Meva
Meva 2015 年 4 月 6 日
I cannot understand the following:
----The problem is that the size of num2str(beta1) is 1*1 and it is counted as row vector but num2str(beta1)' is also 1*1 but it is counted as column vector.
Best
Meva
Meva 2015 年 4 月 6 日
My actual plot command
plot(xx, u13,xx,u23,xx,p12,xx,p22)
If I use yours, how the program undrestand the data to be plotted?
Mahdiyar
Mahdiyar 2015 年 4 月 6 日
the point is that you put one " ' " extera. that is all.
Meva
Meva 2015 年 4 月 6 日
thank you that solved the problem.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2015 年 4 月 6 日

0 投票

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 件のコメント

Meva
Meva 2015 年 4 月 6 日
But it says
Undefined function or variable 'caption'.
when I try it.
Image Analyst
Image Analyst 2015 年 4 月 6 日
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 2015 年 4 月 6 日
I took off the semicolon but it says the same thing. Thanks.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLabels and Styling についてさらに検索

タグ

質問済み:

2015 年 4 月 6 日

コメント済み:

2015 年 4 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by