LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Toeplitz Matrix which each row is a shifted version of the previous row.

Hello,

 

I am having some issues generating a Toeplitz Matrix. All I need to generate this matrix is the first row and the first column.
• In fact, the upper left element of this matrix is common to the first element of the top row and the first element of the leftmost column.
• Each consecutive row of the matrix is shifted by one position.

 Example You may test the functionality of this vi by entering relatively short arrays for the first row and column and see what is produced.
• For example, if the first row is the array [4 3 2 1] and the first column is the array [4 5 6 7 8], the resulting Toeplitz
matrix should be

4 3 2 1  

5 4 3 2

6 5 4 3

7 6 5 4

8 7 6 5 

 

 

 

I was given the following file to work (see attached file)

 

Thank you

 

See file attached 

0 Kudos
Message 1 of 11
(3,155 Views)

So what have you tried?  I would expect to see an Array somewhere (perhaps two one-dimensional Arrays, "Top Row" and "Left Column", with Top Row[0] = Left Column[0] (as they represent the same element of the Toeplitz Matrix).  Actually, I'd probably create a Toeplitz Array, as Arrays are so "built-in" to LabVIEW, and if I needed a Matrix, would do the transformation at the last step.

 

You should attach your code (please attach a VI, not a picture, as we can't edit/test/modify a picture).  It would also help us understand what you know about LabVIEW (many of us have the "urge to teach", particularly as many of us can't "go to work" and are confined to our homes).

 

You, of course, are correct that with the first row and first column, you can (easily) generate the entire Matrix.  You should be able to do it yourself, particularly if you have spent a few hours learning LabVIEW.  Show us your efforts and we can possibly point out the subtle point(s) you missed.  Seeing what Structures and Functions you choose to use will be quite revealing ...

 

Bob Schor

0 Kudos
Message 2 of 11
(3,110 Views)

Bob_Schor,

 

Thanks for the message. I am attaching what I have been trying for days, but I am not sure if this is correct.

 

Also, the instructions say:

Each consecutive row of the matrix is shifted by one position
  • So, the second row of the Toeplitz matrix will start with the second element of the first column, and continue with the first (n-1) elements of the  first row (assuming an mxn matrix).

 

You may test the functionality of this vi by entering relatively short arrays for the first row and column and see what is produced.
• For example, if the first row is the array [4 3 2 1] and the first column is the array [4 5 6 7 8], the resulting Toeplitz
matrix should be • In general, row i will start with the ith element of the first column, and continue with the first (n-1) elements of row i-1.

 

Thanks for your help. I am new to Labview.

0 Kudos
Message 3 of 11
(3,106 Views)

Here are some suggestions:

  • Make life "easy on yourself".  Don't use Complex as the underlying data type, use Dbl or I32 instead (much simpler to "look at" and appreciate).
  • Learn about Arrays and For Loops.  In general, the index ("i" in the little square box at the lower left corner) indexes Array Position (e.g. "row" or "column")
  • Did you notice that part of the process of determining the contents of Row "i" depends on knowing the values in Row "i-1"?  Have you learned about Shift Registers, a nifty way of saving a result from the previous loop iteration?
  • Before trying to write LabVIEW code, sit down with Pencil and Paper.  Assume you know "The previous row contained 3, 1, 4, 1, 5, 9, and the current row starts with 0".  How do you populate the rest of that row?  Can you generalize this?
  • In many programming problems like this, the step "above", that is, the "middle step", is often straight-forward (as this is).  The tricky parts are the "edge cases", how you start the process and how you end it.  Think about that.
  • Once you can do this on paper, try to do the same thing with LabVIEW functions.

Bob Schor

 

0 Kudos
Message 4 of 11
(3,098 Views)

- Unfortunately, our Professor wants us to use the complex instead of DBl. The only 3 elements that he gave us is the Row (complex), Column (complex) and Toeplitz (output).

That is why I am so confused and I am looking for help. We have never used complex before. 

 

-Thanks, I will try to look into arrays and for loops.

- I heard about Shift registers before, but never applied. 

- I am not a programmer but I have tried to do this in paper using my little knowledge of for loops and add registers that I learned like +5 years ago. 

 

Thanks.

 

0 Kudos
Message 5 of 11
(3,093 Views)

Hi Michi,

 

so this is a homework job to learn LabVIEW?

Have you taken any of the training courses until now? (You know they are offered for free until end of April?)

 

Some ideas:

Try to understand how they work while you recreate them…

(The datatype of the inputs is not important for the algorithms, there is no difference if they work with U8, I32 like shown, or CDB data.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
Message 6 of 11
(3,078 Views)

GerW,

 

Thanks for the information. Yes, this is a homework to learn Labview but because the classes now are online is getting more difficult to understand the professor. 

No, I haven't taken any other training. 

 

I will apply those examples that you sent me. If you can provide me more tips, I would appreciate it.

 

Thanks

0 Kudos
Message 7 of 11
(3,060 Views)

@Michi_Fu wrote:

No, I haven't taken any other training. 

 

If you can provide me more tips, I would appreciate it.


He did!  Take the free training offered by NI.  The first page of the Forum lists some Training material, you can search NI.com for "LabVIEW Training", and can search the Web.

 

LabVIEW is an acronym for Laboratory Virtual Instrument Engineering Workbench.  The notion of a "Laboratory" should suggest "doing an Experiment", which should suggest "It's OK to simplify things by using Integers instead of Complex Number" -- you are trying to figure out an algorithm (a "method for doing something"), and it is often easier to "solve a simpler problem" first before tackling the Entire Task.

 

This is why Pencil and Paper make a good starting point.  Watch what you do.  I'll bet you didn't try using pencil and paper, did you?  And if you did, you almost certainly didn't bother with writing down "4+7i, 3-4i, ...", but used "4, 3, ...".  Solve the simple first, understand what you did, then write the code.

 

Bob Schor

0 Kudos
Message 8 of 11
(3,052 Views)

@Michi_Fu wrote:

- Unfortunately, our Professor wants us to use the complex instead of DBl.


Seems you are using LabVIEW 9.0, which is ancient. If you would be using LabVIEW 2019 instead, you would write and test the VI in I32, save it with a vim extension (e.g. "Create-Toeplitz.vim") and it will work correctly as subVI with whatever datatype you wire to it. (Of course you would want to add some type specialization checks to ensure the wired inputs really are 1D arrays, etc.)

 

I came up with something similar to Gerd. Study them all and try to understand the purpose of every single item. Find them in the palette. Look at the help! 😉

 

Note that there are a few landmines if you are not careful reproducing the code from scratch. For example: Why is nothing else wired to "delete from array"? Why is the "built array" output a 1D array instead of a 2D array? 

 

altenbach_0-1585844617664.png

 

Message 9 of 11
(3,034 Views)

Thank you altenbach.

 

I used GerdW info too. I got this when I used the first example that he posted:

 

Michi_Fu_0-1585847239196.png

 

 

I manually typed the values for just the first row and first column and I got this:

 

Michi_Fu_1-1585846918289.png

 

I think is correct, right?

 

I am using Labview 2019, professor's template is old.

 

Thanks.

0 Kudos
Message 10 of 11
(3,027 Views)