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

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)

Change " to '

3 Comments

Hi Madhan Ravi,
Thanks for taking out your precious time and answer my question. Yes It ran succesfully.
thanks mate,
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.
Ok I am using R2015a thats why I faced this error.

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Release

R2015a

Asked:

on 25 Sep 2020

Commented:

on 26 Sep 2020

Community Treasure Hunt

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

Start Hunting!