Home Forums SYSTEM matlab co simulation

Viewing 37 reply threads
  • Author
    Posts
    • #29867
      love kumar
      Participant

      i have few query for matlab co simulation

      1.I am running a matlab co simulation but getting error on line 1 as in ”inner metrix dimension must agree ” i am anot getting what is meaning of this error and how to remove.
      2.Is it possible to remove input port (zero inputport) of because in my project i only need output data which will be generated by matlab itself without any input data. if i am using null point as input signal than simulation giving error as no input signal.
      3. if i am using my script as

      OutputPort1 = InputPort1;

      if(InputPort1.TypeSignal == ’Electrical’)

      cs = length(InputPort1.Sampled);

      if( cs > 0 )

      abc = round(rand(1,1000));
      OutputPort1.Sampled.Signal = round(rand(1,1000)) ;
      end
      end;

      thn i am getting error : time in OutputPort1.Sampled[1]

      how i can handle this problem.

      please help me.

    • #30006
      alistu
      Participant

      Hi love,

      Can you please attach your .osd file along with the Matlab file if it is possible? If you are using null as input to your Matlab component, you sould find a way to create the output vectors which are normally created by the code “OutputPort1=InputPort1;” always suggested by Optiwave to be used as the first line of the Matlab program.

      Regards

    • #31940
      love kumar
      Participant

      could you suggest me how to define output vetcor.

    • #31944
      Aabid Baba
      Participant

      hello love kumar,
      i think you are making a typiing error . You are using inverted parenthesis instead of ‘Electrical’. try this one.

      Regards

    • #31956
      love kumar
      Participant

      hi aabid baba .. as per your sugesstion i have changed the typing mistake but getting same error ..

      • #31960
        Aabid Baba
        Participant

        hello kumar,
        Can you please upload the screenshot of the simulation tab when the error occurs because it shows you the message in the simulation tab where the error is. That may be someone could help in that regard. The matlab code just seems pretty much okay to me. Anyways try to upload the screenshot.
        Regards

    • #32019

      Hi Love Kumar

      Can u please provide the m file along with the osd file so that it becomes easier for us to help u. Matlab code seems fine. and regarding input to matlab component u cannot just keep the input null. u need to feed it with some input which it will process to give u the output. we cannot generate a signal as such in Matlab component as i was facing the same problem in my code.

      Regards

      Burhan

      • #32089
        Aabid Baba
        Participant

        Hello burhan num mina llah,
        I remember that you had a problem with co simulation too but in this case i feel it is an issue regarding proper interfacing thing between MATLAB and optisystem. The code that he has compiles should work fine because its a basic program. I feel he must be doing some wrong in interfacing and then getting signals out of the MATLAB module.

    • #32100
      SAHIL SINGH
      Participant

      hello kumar,
      I suggest you to first upload the screenshot of the simulation tab when the error occurs in your design.Also as mentioned by Burhan provide the m file along with the osd file so that it becomes easier for us to help u.

      Regards
      Sahil Singh

      • #32106
        Aabid Baba
        Participant

        yeah sahil and burhan are right. You should upload the m.file along with the osd file of your system design so that it becomes convenient for us to figure out where the problem lies.
        anyway looking forward for the upload.
        Regards

    • #32427

      Hi.
      Can u plz upload the snapshot of the window that shows the error. It is convenient to diagnose the problem. The code seems to be ok…
      upload the m.file and the osd file…both
      thanks and regards

    • #32518

      Hi All

      Yes Aabid i also think he has the problem in the interfacing part. I believe he might not be able to interface it correctly. Anyways Kumar i would suggest that when u double click on Matlab component Provide the path in the option Mentioned and then mention the m.file name seperately and do remember to mention the name followed by semicolon as it takes it as a command and then only it processes it and don’t forget to load the matlab component. I hope u are doing it acoording to these steps and i hope it should work . Else i would still suggest to please upload the .m file and .osd file, that would be helpfull to understand ur query.

      Best Regards

      Burhan

    • #33051
      love kumar
      Participant

      hi all… thanks for your suggestions.. what i have analysis the problem i mention was in code .. i resolved that problem .. but to interfece that code with matlab component i have to define phase of sine genrator in radian… is there any option .. the change is n=code is explaed with a example

      matlab we take as
      a= rand(1,1000);
      x= -pi:0.01:pi;
      sin(x)*a
      getting error with this code

      but

      we have to take it as

      a= rand(1,1000);
      x= -0.0034:0.01:0.0034;
      sin(x)*a

      we have to set vale of x in sine generator… how cud we do it

      • #33061

        HI LOVE KUMAR
        Burhan num can help you over this..if the problem is lies with interface she can definitely help you..but what i see her is that you are facing an issue with conversions…as mentioned in your recent post over the same query . I would like to suggest u to change the phase into radains in the MATLAB code itself if possible…may be that wud help..
        Thanks and regarrds

    • #33436

      Hi All

      Love kumar if you have any query regarding interfacing your matlab code with optisystem i can surely help you out but writing a matlab code or removing errors would be difficult for me i would suggest u to ask this query to some coding expert. As it is quite cumbersome to design a code and that too a code that u need to interface with optisystem. Surely u can inform me about the interfacing issue. Happy to help.

      Regards

      Burhan

    • #33448
      love kumar
      Participant

      hi burhan … i m attaching there the file .osd, mfile and snapshot of error please find he attachment here with … i just want a output at the mz modulator and Matlab component …kindly provide me the solution .. just a sine signal need to b multiply with a random number ..

    • #33457

      Hi Love Kumar

      Actually this time i am not having access to the software i would try having a look at the matlab component interfaced tomorrow. I did see your code . It seemed ok but it is some problem in the code itself as i was able to see the screen shot and m. File only. I would be able to suggest further after having a look at your model.

      Regards

      Burhan

    • #33472
      love kumar
      Participant

      hi burhan … i have attached the matlab code with the file name as test1.m in my last last … looking for a psotive response from your end ..

    • #33477

      Hi love kumar

      Since i am not able to view ur design or model yet(no access to license) i cannot infer what is the input u have provided to the matlab component. I can only see your m.file and the screenshot and from that i can say as it clearly mentions that the input signal is not what your program demands. Can u brief me about that or i would suggest wait till tomorrow i will try to help u out. And can u please tell me where did u find this code from or u wrote it urself.

      Regards

      Burhan

    • #33479
      love kumar
      Participant

      i have written this code … n i was not getting any other suitable electrical component for input to matlab function.. waiting for tomorrow

    • #33482

      Hi love kumar

      So far i know about the code it seems quote ok but i believe there is some problem in the input you are providing to the matlab component. Let me check it tomorrow. I can assist u further afer that only. Till then may somebody else came up with a solution. Hope!

      Regards

      Burhan

    • #33525
      love kumar
      Participant

      uplaoding .osd file again…

    • #33532

      Hi Love Kumar

      Can u please upload a screenshot of ur .osd file or i would say the design/model.

      Regards

      Burhan

    • #33534
      MHD NA
      Participant

      If you are using null as input to your Matlab component, you sould find a way to create the output vectors which are normally created by the code “OutputPort1=InputPort1;” always suggested by Optiwave to be used as the first line of the Matlab program.

    • #33536
      love kumar
      Participant

      hi burhan … i am attaching the snapshot of the system ..

    • #33538
      love kumar
      Participant

      hii MHD.. i ma agree with you .. but i m not getting the way how to define output vector .. if we use null as input signal .. if yu have any information please share ..

      regards

    • #33582
      Sanjeev kumar
      Participant

      Hello Burhan,
      I was going to demodulate a CPFSK signal using matlab component as there is not any component available to demodulate CPFSK data. how can we demodulate it. or how can we get output as binary from input as CPFSK data. can you help me over this? Also i am attaching here .m file where i was going to construct an MSK modulator. once i able to complete it i think it would not be impossible for me consturct CPFSK demodulator too. the attached files are as one for optisystem other is msk modulation in matlab only. how can we run optisytem matlab code by using same parameters as matlab only file.
      thank you.

    • #33613
      SAHIL SINGH
      Participant

      Hello Burhan,

      I too have this query that how can we run optisytem matlab code by using same parameters as matlab only file… It seems that you have a lot of knowledge on the aforementioned topic… Hope to hear from you soon..

      Regards

      Sahil Singh

    • #33696

      Hi love kumar

      I am not able to understand why this matlab component is showing error regarding the input port . It seems quite fine. I would suggest u to write this code i mean copy paste n save it again at some different place and give a new path. I hope it should work.
      As such I can’t see any problem with design and code.

      Regards

      Burhan

    • #33701
      Naazira Badar
      Participant

      Hi all.

      Yes , Burhan has explained every thing right in an elaborative manner.
      That is the way to go about it.
      And she’s right we can’t keep the input set to null. That should be taken care of.

      Regards
      Naazira.

    • #33703

      Hello sanjeev kumar

      As of now i am not an expertise in coding but regarding the simulation of matlab code in optisystem you just need to keep in mind the signal types and sampled lengths. Else the matlab code follows the similar logic as in the matlab software itself. The major difference in the code for optisystem is we define ports with the same name as in optisystem and that is e.g InputPort keeping in mind tha caps as well. Rest for coding a demodulator i am sorry I don’t have much knowledge of coding. But since u have coded modulator it should be easy for you to design demodulator. Best of luck!

      Regards

      Burhan

    • #33705

      Hello sahil singh

      I hope you got the answer for your query from my comment for sanjeev kumar that except for few things like signal type , sampled length etc. and mentioning the ports correctly, rest the code doesn’t follow some other logic . It is same as in the matlab software itself without much difference.

      Regards

      Burhan

    • #33714
      SAHIL SINGH
      Participant

      Hello Burhan,

      I thank you for explaining every thing right in an elaborative manner…. Indeed i got my answer… Indeed this information will be very helpful… Really appreciate your efforts…

      Regards

      Sahil Singh

    • #33733
      Sanjeev kumar
      Participant

      Yes definitely i know that burhan means we should keep in mind about the terms to be used as parameters in matlab co simulation. can we demodulate CPFSK and MSK data using PSK sequence decoder.?

    • #33756
      love kumar
      Participant

      hi burhan .. i did it many time as you suggest to cretae a new m file .. but unfortunately i get same error every time.. i m too much confused why this is happening ..i did other matlab co simulations also but hey are working fine ..

    • #33801

      Hi All

      you are most welcome sahil singh


      @sanjeev
      kumar.. you are welcome and it feels nice that i proved to be helpfull for you people. and regarding your query now. i very much believe that if you had been able to code the modulator then certainly there should not be any issue in redesigning the modulator i mean coding it. but since u are asking that u would decode that with PSK sequence decoder, i would say no just try to go for the matlab again as u have modulated with a different modulator so u should decode with a corresponding decoder/demodulator.

      Regards

      Burhan

    • #33804

      Hi Love Kumar

      i am really sorry that i can’t help u in this i have put forth all i knew about this matlab co-simulation.Since matlab in itself is a vast field and coding is really a difficult thing for a commoner like me . i only have the basic knowledge of matlab and on that basis i seemed to believe that your code is right but may be there would be some problem while interfacing it with the software (optisystem). it shows problem in the incoming signal so u can also try it with some other electrical signal.

      Regards

      Burhan

    • #33868
      love kumar
      Participant

      hi burhan .. first of all thanks for spending your time on my problem .. burhan do we have any possibility in matlab component that we can define struct for input and output signal according to our requirement … i am guessing that that may b helpful to solve this issue

    • #33882

      Hi love kumar

      ohhhh yeah we can definitely define the type of signal it takes in the matlab component. u just have to double click on the componet and there is an option to even change the number of inputs and outputs and just below that there is mentioned what type of signal it takes and there are 4 options..electrical, binary, m-array and optical. u can keep any of these and likewise should be the code. if for example your code does not deal with the type of signal you will keep as input then please keep in mind that ur matlab component would be simulated without showing any error. so make sure that the code u have inserted is working by comparing your results without the matlab component also. hope it helps.

      Regards

      Burhan

    • #33953
      love kumar
      Participant

      hi burhan.. i ii totatlly agree with you.. but my mean to say was can we change teh struct of input output strcut.. as we all know that matlab work on matrix structure..i an guess that outport of the matlab componet give result in 1×1 structure .. event in documentation in the matlab co simulation they had pointed about array structure .. even whn to write OutPort1= InputPort1: in matlab i starting creating a structure …do we have any option to define it according to our requirement

    • #33969

      Hi Love Kumar

      I understood your point and i know what you are referring to . Look the command that outputport 1 = InputPort 1 is written by default at the beginning as we want the incoming signal to pass to the output and regarding you type of signal issue the thing is that when you write a program you obviously write a code accordingly in or to get the required type of signal at output. And when we load the matlab file it automatically updates the type of signal in the code itself provided the code is valid and makes sure about the type of signal. Its all within the code and as such u need not make changes and even if u want to u still can.

      Regards

      Burhan

    • #39331
      Jamal
      Participant

      @burhan

      As you have quite a lot idea of matlab interfacing, I’d be pleased if you could help me with the interfacing.

      I have initialised my output with OutputPort1 = InputPort1; and after doing all the work on the input signal I want to assign it to output.
      I end the code with OutputPort1.Sampled.Signal = InterleavedSignal
      In matlab after this assignment, I can successfully plot the OutputPort1.Sampled.Signal but the signal does not show up back in optisystem

      • #39377
        Damian Marek
        Participant

        Next time if you have a new question please start a new topic! Without your project file or matlab file I can only guess at the problem, but I do believe it is because your output port is not of the correct type. In OptiSystem, open the Matlab component and go to the Outputs. The type of the output should be set to either electrical or optical depending on what it is you are doing.

Viewing 37 reply threads
  • You must be logged in to reply to this topic.