Anyone here know MatLab? Programming...

Ford SportTrac Forum

Help Support Ford SportTrac Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Jeff C

Well-Known Member
Joined
Aug 3, 2003
Messages
3,990
Reaction score
0
Location
Auburn, AL
Our teacher doesn't exactly teach, he just kinda tells us what he wants in the end. Now, as someone with little programming knowledge, I'm pretty much lost. Basically we have to make a program that will determine if two user-created matrices can be added together, that is, if they're the same size, and then if they can be multiplied, the rows of the first matrix equals the columns of the second, then finally display messages of whether or not each function can be performed (note: doesn't have to actually do it +/*).



I don't want anyone doing the work, I'd just like someone to point me in the right direction. It's not due til Sunday night, but I'm planning on going home this weekend, so I won't really be able to work on it...thanks in advance.
 
Jeff,

I'm not familiar with MatLab, but most programming languages have similar rules and functions and only the syntax of the language differs. Most languages have built in commands to validate data such as determine if the data is numeric or alpha, etc.



I think the simplest method would be to test if the matrix cell contains a numeric value, if True, then you could test if it's equal to zero. If it's not zero, you can perform any arithmatic function on the number. If it is zero, you can also do any arithmatic function except divide?



...Rich
 
Last edited by a moderator:
Use the "Size" function.



Syntax



d = size(X)

[m,n] = size(X)

m = size(X,dim)

[d1,d2,d3,...,dn] = size(X)



So, you can do:



if size(a) = size(b) then you can add



For multiplication you can compare size(a) to size(b transpose)



if size(a) = size(b') then you can multiply



You will have to format statement in a proper manner and fill in the code.





Hope this helps.





 
Last edited by a moderator:
Bill-



Are you a Rolla guy? I am a former Miner, but it wasn't until your post that brought back sooo many bad memories that I had repressed over the last four years (last time I dealt with MCad). All that money and professional help has now been wasted.... thanks.:p



 
Rolla? Where's that? Engineering school? I'm a Purdue grad. Been through Rolla many times on the way to West Plains where I spend the total of a year of my life. Now them's some bad memories.
 

Latest posts

Top