Error: The input character is not valid in MATLAB statements or expressions.

41 views (last 30 days)
I have tried to tun the following code(R2015a)
W=input('Enter width in m: ');
A=input('Enter area in sq. m: ');
%Since the hypotenuse of the right angle triangle is W
%and the rest of the side are D
%W^2=D^2+D^2
%=> D^2=(W^2)/2
%=> D=sqrt((W^2)/2)
D=sqrt((W^2)/2);
%Side D, height of triangle Ht and half of W make a right triangle
%D is hypotenuse, So
%D^2=Ht^2+(W/2)^2
%Ht=sqrt(D^2-(W/2)^2)
Ht=sqrt(D^2-(W/2)^2);
%area of triangle
A1=0.5*W*Ht;
%area of rectangle
A2=A-A1;
%finding length
L=A2/W;
fprintf("Length in m: %.3f\n", L);
%length of fence
LFence=2*(W+L)+W+2*D;
fprintf("Length of fence in m: %.3f\n", LFence);
But it is showing like this :
fprintf("Length in m: %.3f\n", L);
|
Error: The input character is not valid in MATLAB statements or expressions.

Answers (1)

madhan ravi
madhan ravi on 25 Sep 2020
Change " to '
  3 Comments
Steven Lord
Steven Lord on 25 Sep 2020
madhan ravi showed you what to do. The reason why you need to do this is that the ability to create a string array using double quotes ("") was introduced in release R2017a.

Sign in to comment.

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!