Code Segment works in Command Window but not in script
5 次查看(过去 30 天)
显示 更早的评论
Error Message: "Incorrect dimensions for matrix multiplication."
Variables: X(5000 x 400) and theta (10 X 400);
Code: prob = X * theta';
This code works in the command window but when I try to run this segment of code in a script it gives me the shorten-error message above. Any suggestions on how to make the code run in the script?
2 个评论
Walter Roberson
2021-1-17
dbstop if error
Then run your code. When it stops at that line,
size(X), size(theta)
采纳的回答
Cris LaPierre
2021-1-17
Appears to work just fine. Do you define X or theta somewhere in your script with different dimensions? Perhaps clear your workspace?
X=rand(5000,400);
theta = rand(10,400);
prob = X*theta'
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Debugging and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!