none
Convert a Matlab cod to Visual Basic 2010

    Question

  • Hello,

    can you help me and convert this Matlab cod to Visual Basic 2010.

    y12=10-j*20;

    y13=10-j*30;

    y23=16-j*32;

    y33=y13+y23;

    V1=1.05+j*0;

    %format long

    iter =0;

    S2=-4.0-j*2.5;

    P3 = 2;

    V2=1+j*0;

    Vm3=1.04;

    V3=1.04+j*0;

    for

    I=1:10;

    iter=iter+1

    E2 = V2;

    E3=V3;

    V2 = (conj(S2)/conj(V2)+y12*V1+y23*V3)/(y12+y23)

    DV2 = V2-E2

    Q3 = -imag(conj(V3)*(y33*V3-y13*V1-y23*V2))

    S3 = P3 +j*Q3;

    Vc3 = (conj(S3)/conj(V3)+y13*V1+y23*V2)/(y13+y23)

    Vi3 = imag(Vc3);

    Vr3= sqrt(Vm3^2 - Vi3^2);

    V3 = Vr3 + j*Vi3

    DV3=V3-E3

    end

    the result:

    iter =

        10


    V2 =

       0.9706 - 0.0457i


    DV2 =

      -3.3824e-07 - 2.7125e-06i


    Q3 =

        1.4617


    Vc3 =

       1.0400 - 0.0091i


    V3 =

       1.0400 - 0.0091i


    DV3 =

      -1.8650e-08 - 2.1428e-06i

    Sunday, March 16, 2014 3:37 AM

All replies

  • Perhaps you could use Matlab coder to convert Matlab code from Matlab to C++. Then download Tangible Free Product Editions C++ to VB converter and convert the code that way.

    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.

    Sunday, March 16, 2014 3:46 AM
  • Hello,

    can you help me and convert this Matlab cod to Visual Basic 2010.

    This question has been asked here:
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/924c7550-ce6a-444c-8823-08275cfa7d75/visual-basic-2010?forum=vbgeneral

    If a different thread is now required then you should indicate what additional information you need about the solutions already posted there.

    Sunday, March 16, 2014 4:01 AM
  • In fact,I have difficulty to convert this part.

    V2 = (conj(S2)/conj(V2)+y12*V1+y23*V3)/(y12+y23)

    DV2 = V2-E2

    Q3 = -imag(conj(V3)*(y33*V3-y13*V1-y23*V2))

    S3 = P3 +j*Q3;

    Vc3 = (conj(S3)/conj(V3)+y13*V1+y23*V2)/(y13+y23)

    Vi3 = imag(Vc3);

    Vr3= sqrt(Vm3^2 - Vi3^2);

    V3 = Vr3 + j*Vi3

    DV3=V3-E3

    Sunday, March 16, 2014 4:07 AM
  • In fact,I have difficulty to convert this part.

    Post the code that you have created an someone may be able to spot where the problem is.

    Sunday, March 16, 2014 5:06 AM
  • Hello,

    could you please find a Visual Basic Code from this Matlab Code.

    let's assume that

    Pgg=[ 35.0907  64.1317  52.4767]

    cost function=[200   7      0.008

                         180  6.3     0.009

                         140   6.8     0.007]

    if

    exist('Pgg')~=1

    Pgg=input(

    'Enter the scheduled real power gen. in row matrix ');


    else

    ,end

    if

    exist('cost')~=1

    cost = input(

    'Enter the cost function matrix ');


    else

    , end


    ngg = length(cost(:,1));

    Pmt = [ones(1,ngg); Pgg; Pgg.^2];


    for

    ii = 1:ngg

    costv(ii) = cost(ii,:)*Pmt(:,ii);


    end


    totalcost=sum(costv);

    fprintf(

    '\nTotal generation cost = % 10.2f $/h \n', totalcost)

    Saturday, March 22, 2014 4:52 AM
  • Why? You can create a run time dll from matlab.  Then add the dll to your VB project as a reference.  You can then call the matlab function like any other VB method.

    jdweng

    Saturday, March 22, 2014 9:22 AM
  • You should try Matlabs converter that converts Matlab code to C++. Then convert the C++ code to Visual Basic using a C++ to Visual Basic converter.

    I believe I already mentioned this in another post about Matlab code by you - Convert a Matlab cod to Visual Basic 2010 - or did you have an inability to do that on your own for some reason?

    Or get the documentation from Matlabs website and convert all the code yourself - MATLAB Documentation - once you learn what your MATLAB code is.

    Why would you think somebody could convert Matlab code to Visual Basic code in a Visual Basic forum? Also this isn't a forum for converting code from some language to Visual Basic.


    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.



    Saturday, March 22, 2014 4:21 PM