take the following code: in matlab

Assuming you're asking how to write the following code in MATLAB:

main.m
x = 5
y = 10
if x < y:
    print("x is smaller than y")
else:
    print("x is greater than or equal to y")
107 chars
7 lines

Here's the equivalent MATLAB code:

main.m
x = 5;
y = 10;
if x < y
    disp('x is smaller than y');
else
    disp('x is greater than or equal to y');
end
111 chars
8 lines

Note that semi-colons are used to suppress output in MATLAB, and disp() is used to print text to the console.

related categories

gistlibby LogSnag