How can i solve the " Subscripted assignment dimension mismatch. Error in fi2 (line 12) u(:,1)= -sin(pi.*x) " ?

1 次查看(过去 30 天)
here is the code :
a = input('Insert the value of a: ');
CFL = input('Insert the value of CFL: ');
dx = input('Insert the value of dx: ');
dt = (CFL * dx)/ abs(a);
lambda = (dt/dx)
tf = input('Insert final time : ');
N = input('Insert the value of N: ');
x = linspace(-1,1,N);
%choose test case:
tc= input('choose test case number : ');
if tc == 1
u(:,1)= -sin(pi.*x)

采纳的回答

ME
ME 2017-12-11
I have just run this code in R2016a and it did not produce an error when I chose a random set of input parameters. Was there a specific set of input parameters that produce this issue for you?
  4 个评论
ME
ME 2017-12-11
Just tried again after inputting the parameters you suggested with tc=1 and did not get the error.
Apologies for asking a stupid question but in your script I assume you have the 'end' that is missing from the code in your problem description?
Also, is there supposed to be more code after the below lines? If not then your script produces no u array unless tc=1.
if tc == 1
u(:,1)= -sin(pi.*x)
guetty abboud
guetty abboud 2017-12-11
yes of course there are other conditions for tc. and no i didn't forget the end in the code. thanks for noticing though. please may you refer to my other question which is a new error I am confronting ?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by