{"id":131,"date":"2013-12-08T15:41:42","date_gmt":"2013-12-08T15:41:42","guid":{"rendered":"http:\/\/speculateforever.wordpress.com\/?p=17"},"modified":"2013-12-08T15:41:42","modified_gmt":"2013-12-08T15:41:42","slug":"scripts-for-matlab-exercises-in-acc-lab-of-first-year-sit","status":"publish","type":"post","link":"https:\/\/moodle.sit.ac.in\/blog\/scripts-for-matlab-exercises-in-acc-lab-of-first-year-sit\/","title":{"rendered":"Scripts for Matlab exercises in ACC lab of first year SIT"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"wp-image-13 alignright lazyload\" alt=\"Prabodh C P\" data-src=\"http:\/\/speculateforever.files.wordpress.com\/2013\/02\/prabodh-c-p1-e1382610428637.jpg?w=286&#038;resize=156%2C163\" width=\"156\" height=\"163\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 156px; --smush-placeholder-aspect-ratio: 156\/163;\" \/><\/p>\n<p>Recently I wrote a few Matlab scripts for the ACC lab. I am going to post them here. If you do not have a valid Matlab license do not despair. All these run successfully on\u00a0<a title=\"GNU Octave\" href=\"https:\/\/www.gnu.org\/software\/octave\/\">GNU Octave\u00a0 <\/a>as well which can be downloaded from the following link<\/p>\n<p>https:\/\/www.gnu.org\/software\/octave\/<\/p>\n<p>If you are looking for a graphical front end try <a href=\"http:\/\/sourceforge.net\/projects\/qtoctave.berlios\/\">QtOctave<\/a> which is also available at the following link<\/p>\n<p>http:\/\/sourceforge.net\/projects\/qtoctave.berlios\/<\/p>\n<p>Use any plain text editor like gedit, vi, emacs&#8230;&#8230; to create the script file and save with a <strong>.m<\/strong> extension<\/p>\n<p>All the scripts can be downloaded by clicking on the link below<\/p>\n<p><a href=\"https:\/\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2013\/12\/989e9-matlabaccfinal3.pdf\">Click here to download all Matlab Scripts<\/a><\/p>\n<p><span style=\"color:#ff0000\"><strong>Script 1:<br \/>\n<\/strong><\/span><br \/>\n<em>To find the sum of first \u2018N\u2019 numbers that are divisible by 5 and not divisible by 5.The user has to accept the value of \u2018N\u2019 from the input device.<\/em><\/p>\n<pre>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\u00a0\u00a0 \u00a0Description:\u00a0\u00a0 \u00a0Script to find sum of elements divisible by 5\n%\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0and sum of elements not divisible by 5 among \n%\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0first 'N' integers\n%\u00a0\u00a0 \u00a0Author:\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Prabodh C P, Asst.Professor, Dept of CSE, SIT\n%\u00a0\u00a0 \u00a0Date:\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a007-12-2013\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nclear all;\nclc;\ntotsum5=0;\ntotsum=0;\nn=input('Enter number of terms');\nfprintf('\\nNo of terms is %d\\n',n);\nfor i=1:n,\n\u00a0\u00a0 \u00a0%V(i) = input('Value');\n\u00a0\u00a0 \u00a0V(i)=i;\n\u00a0\u00a0 \u00a0if rem(V(i),5) == 0\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0totsum5 = totsum5 + V(i);\n\u00a0\u00a0 \u00a0else\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0totsum = totsum + V(i);\u00a0\u00a0 \u00a0\n\u00a0\u00a0 \u00a0end\nend\nfor i=1:n,\n\u00a0\u00a0 \u00a0fprintf('%d\\t',V(i));\nend\nfprintf('\\nSum of elements divisible by 5 is %d\\n',totsum5);\nfprintf('\\nSum of elements not divisible by 5 is %d\\n',totsum);\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\u00a0 End of script\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<\/pre>\n<p><span style=\"color:#ff0000\"><strong>Script 2:<br \/>\n<\/strong><\/span><\/p>\n<p><em>To perform row wise and column wise concatenation of two matrices<br \/>\nand to display row number and column number of even elements in a matrix.<br \/>\n<\/em><\/p>\n<pre>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%Description\t:\tScript to perform row wise and column wise  \n%\t\t\tconcatenation of  two matrices and to display row\n%                       and column number of even elements in a matrix \n%Author\t        :\tPrabodh C P, Dept of CSE, SIT\n%Date\t\t:\t07-12-2013\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\nclear all;\nclc;\nm=input('Enter no of rows');\nn=input('Enter no of cols');\n\nfprintf('\\nEnter elements of Matrix 1\\n');\nfor i=1:m,\n    for j=1:n;\n        A(i,j)=input('Value=');\n    end\nend\n\nfprintf('Entered Matrix 1 is\\n');\ndisp(A);\n\nfprintf('\\nEnter elements of Matrix 2 is\\n');\nfor i=1:m,\n    for j=1:n;\n        B(i,j)=input('Value=');\n    end\nend\n\nfprintf('Entered Matrix 2 is\\n');\ndisp(B);\n\nfprintf('Row wise Concatenation\\n');\n%C=[A,B];\nC=horzcat(A,B);\ndisp(C);\n\nfprintf('Column wise Concatenation\\n');\n%D=[A;B];\nD=vertcat(A,B);\ndisp(D);\nfprintf('\\n');\n\nfprintf('\\nEven elements of Matrix 1 is\\n');\ndisp(A);\nfprintf('\\n');\nfor i=1:m,\n    for j=1:n;\n        if (rem(A(i,j),2)==0)\n            fprintf('\\nElement = %d (row = %d , col = %d)\\n',A(i,j),i,j);\n        end\n    end\nend<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Recently I wrote a few Matlab scripts for the ACC lab. I am going to post them here. If you do not have a valid Matlab license do not despair. All these run successfully on\u00a0GNU Octave\u00a0 as well which can be downloaded from the following link https:\/\/www.gnu.org\/software\/octave\/ If you are looking for a graphical front [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[12,36,42],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-acc-lab","tag-matlab","tag-sit"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":0,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"wp:attachment":[{"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}