MATLAB: Error: File: Symbolic_Relationships.m Line: 17 Column: 11 The expression to the left of the equals sign is not a valid target for an assignment.

equals signleftMATLABtarget for an assignmentthe expression to the left of the equals sign is not a valid target for an assignment.

1 %Symbolic relatioships
2 %Justin Sheldon
3 %MATLAB Assignment #1 EGR 271
4
5 clear;
6 clc;
7
8 fprintf('Enter 1 to find i(t) given q(t)\n')
9 fprintf('Enter 2 to find q(t) given i(t) over a range \n')
10 fprintf('Enter 3 to find p(t) given w(t)\n')
11 fprintf('Enter 4 to find w(t) given p(t)\n')
12 Choice=input('');
13
14 if(Choice==1)
15 [
16 fprintf('i(t)=dq/dt\n')
17 coeff=input('Please enter the coeffecent before the e: ');
18 exp=input('Please enter the exponent ignoring the t variable: ');
19 coeff1=coeff*exp;
20 fprintf('i(t) = %0fe',r1)
21 fprintf('^ %0t',exp)
22
23 ]
24
25 elseif(Choice==2)
[
]
elseif(Choice==3)
[
]
elseif(Choice==4)
[
]
end

Best Answer

  • The error is due to the square brackets that you used to denote a block for if condition. Square brackets are not required to denote a block in MATLAB.
    if(Choice==1)
    fprintf('i(t)=dq/dt\n')
    coeff = input('Please enter the coeffecent before the e: ');
    exp = input('Please enter the exponent ignoring the t variable: ');
    coeff1 = coeff * exp;
    fprintf('i(t) = %0fe',r1)
    fprintf('^ %0t',exp)
    elseif(Choice==2)
    % Your code goes here


    elseif(Choice==3)
    % Your code goes here
    elseif(Choice==4)
    % Your code goes here
    end
    This code would probably help.