Scilab Program - loop, if else basics.. by hdrohithd |

Scilab Program - loop, if else basics..

Author: hdrohithd


A matrix with the elements 2 and 3 "every row of A matrix contains at least one element with the value 2 then the system has a solution, otherwise system has no solution.
 

system has solution
 
system has no solution
 
clc
clear
close
//given matrix with entries 2,3
m_matrix = [2 3 3 3;2 3 2 3;2 2 2 3;3 3 3 3;]
disp(m_matrix)

//get it's row and column
m_size = size(m_matrix)
m_rows = m_size(1)

for i = 1:m_rows
    //get each row
    r = m_matrix(i,:);
    //find no of 2's
    flag = 1
    tows = find(r==2);
    if isempty(tows) then
        flag = 0
        break;
    end
end

if flag then
    disp("System has solution..")
else
    disp("System has no solution..")
end

For Scilab free course: https://dvrblacktech.pythonanywhere.com/Courses/scilab-way-towards-signal-processing-course

Comments: (1)

Please loging to post comment

Amutha 3 years, 3 months ago
I have a test with this.... I got an idea. THANK YOU SO MUCH.

hdrohithd 3 years, 3 months ago
You are welcome..