Can anyone help with vertcat?

m=0.05;
q=0.05;
B=[0.01;0.01;0.01];
vx=linspace(-10,10,1000);
V=[vx;1;2];
F=cross(V,B);
magF=sqrt(dot(V,B));
plot(vx,magF);
attempting to evaluate lorentz force by varying vx between -10 an 10. showing as a vertcat errorand refering me to the V vector displaying message saying dimesions of matirx are not consistent

回答 (1 件)

Adam
Adam 2018 年 2 月 28 日
編集済み: Adam 2018 年 2 月 28 日

0 投票

vx=linspace(-10,10,1000);
returns an array with 1 row and 1000 columns.
You would need to use
V=[vx';1;2];
to add 1 and 2 to the end of this, if that is your intention. I suspect that is not your intention, but you can't really concatenate with two scalars in any other way.
Errors like this are easy to spot the cause of with the debugger though and just typing
size( vx );
on command line after its creation.

カテゴリ

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

質問済み:

2018 年 2 月 28 日

編集済み:

2018 年 2 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by