Build Matrix A for Cross Product Multiplication of 2 Vectors

Click For Summary

Discussion Overview

The discussion revolves around building a matrix for cross product multiplication of two vectors in MATLAB, as well as creating a random table of names and ages. Participants explore the challenges of implementing these tasks programmatically within MATLAB.

Discussion Character

  • Homework-related
  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant seeks to construct a matrix A such that the determinant represents the cross product of two vectors, specifically asking for guidance on coding this in MATLAB.
  • Another participant suggests using MATLAB's built-in cross-product function, noting the complexity of the task and potential dimension mismatch errors when trying to include unit vectors in a matrix.
  • A participant acknowledges the simplicity of using the built-in function but indicates that the homework requires a different approach.
  • There is a request for assistance in generating a random table of names and ages, with questions about creating a matrix that includes strings as well as numbers.
  • One participant recommends using the sprintf function in conjunction with random number generation to achieve the desired outcome.
  • Another participant expresses difficulty in understanding how to use the sprintf function and requests further clarification on its application.
  • There are inquiries about specific coding attempts and the errors encountered, with a focus on understanding the functionality of the sprintf function.

Areas of Agreement / Disagreement

Participants express varying levels of understanding and approaches to the problems presented. There is no consensus on the best method for constructing the names matrix, and multiple viewpoints on how to effectively use MATLAB's functions are evident.

Contextual Notes

Participants mention limitations in their understanding of MATLAB, particularly regarding the use of specific functions and the handling of data types within matrices. There are unresolved questions about the implementation of the sprintf function and the construction of matrices that include both strings and numbers.

Who May Find This Useful

This discussion may be useful for students or individuals learning MATLAB who are interested in matrix operations, cross products, and data manipulation involving mixed data types.

Dell
Messages
555
Reaction score
0
i want to build a matrix that can solve cross product multiplication of 2 vectors, building a matrix A so that

detA=PxS

A=

[tex]\hat{i}[/tex] [tex]\hat{j}[/tex] [tex]\hat{k}[/tex]
P1 P2 P3
S1 S2 S3


how do i build a code so that my det will give me a vector answer?
 
Physics news on Phys.org
Why wouldn't you just use MATLAB's built in cross-product?

Doing what you're asking (in MATLAB) is a somewhat complicated problem. It's easy to do this by hand, but MATLAB is a bit different. Think about how you would do this by hand - what are [tex]\hat{i}[/tex], [tex]\hat{j}[/tex], and [tex]\hat{k}[/tex]?

Since each of these is a vector (three components in 3-space), MATLAB won't let you create a matrix containing these vectors - you'll get a dimension mismatch error. What you might be able to do is define symbols (do you have the symbolic math toolbox?) for i, j, and k, and use these in your matrix. This will give you an answer, but it won't be very useful, because you won't be able to operate on your result.

-Kerry
 
thanks, its one of the homework problems i have, using the cross function is much simpler but i am meant to doo it this way.

another problem i need to do is make a table containing
names and ages

name1 48
name2 33
name4 90
...
namen 22

totally randomly, at least 15 names, and then perform a number of tasks on them, is there a way i can tell MATLAB to make the random table or do i need to plug in all the names and ages, can i make a nx2 matrix where the 1st colomn is made up of words not numbers? also can i tell MATLAB to make name(n) where n runs from 1->15
 
Look into the sprintf function - that should do what you need. You can use it in conjuction with randn.

-Kerry
 
thanks a lot, btw i managed the det using
syms i j k
 
still haven't managed to build the names matrix
name1 48
name2 33
name4 90
...
namen 22

could you please help, or if possible write the code i need, i didnt really understand the ssprintf function.

even if i try making the matrix it doesn't work, ie
a=['name1' 48; 'name2'...] i am only managing to make matrices of numbers
 
Can you show me how you're trying to use the sprintf function? I don't understand what problems you're having if you don't show your work. Tell me what you don't understand, what errors your getting, what behavior you want vs. what behavior you're getting.

-Kerry
 
i just don't know what it actually does, what to type to use it, the help fiile didnt really mae sense to me, i am pretty much a MATLAB novice, only had a couple of lessons so far
 
Scroll to the bottom of the help entry - there are examples there. Try them out. If you still have questions, I will be happy to help. You can cite specific parts of the examples that you don't understand. MATLAB does a very good job with their documentation, and I don't want to just repeat it here. I can give you my own examples, and my own explanation of what it is doing, but if you don't tell me what it is that you don't understand, my explanation will be very similar to what you will find in the MATLAB documentation.

-Kerry
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 9 ·
Replies
9
Views
1K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
1K