Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to write this code in matlab?

  1. Jan 31, 2012 #1
    M0=100;
    var0=100;

    i=1:478
    j=1:448
    if(temp(i,j)>M)
    G(i,j)=M0+sqrt(double((var0*power((temp(i,j)-M),2))/V));
    else

    G(i,j)=M0-sqrt(double((var0*power((temp(i,j)-M),2))/V));

    Where temp(i,j) is an matrix. This code is not working. I am getting the values of G as 100. Please help me with the correct code. I am new to matlab.
     
  2. jcsd
  3. Feb 1, 2012 #2

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    temp(i,j)????
     
  4. Feb 1, 2012 #3

    jhae2.718

    User Avatar
    Gold Member

    What is temp()? What is your expected output?

    In code tags:
    Code (Text):

    M0=100;
    var0=100;

    [color=#008000]i[/color]=1:478;
    [color=#008000]j[/color]=1:448;
    [color=#008000][b]if[/b][/color](temp([color=#008000]i[/color],[color=#008000]j[/color])[color=#666666]>[/color]M)
        G([color=#008000]i[/color],[color=#008000]j[/color])=M0[color=#666666]+[/color][color=#008000]sqrt[/color](double((var0[color=#666666]*[/color]power((temp([color=#008000]i[/color],[color=#008000]j[/color])[color=#666666]-[/color]M),2))[color=#666666]/[/color]V));
    [color=#008000][b]else[/b][/color]
        G([color=#008000]i[/color],[color=#008000]j[/color])=M0[color=#666666]-[/color][color=#008000]sqrt[/color](double((var0[color=#666666]*[/color]power((temp([color=#008000]i[/color],[color=#008000]j[/color])[color=#666666]-[/color]M),2))[color=#666666]/[/color]V));
    [color=#008000][b]end[/b][/color]
     
     
  5. Feb 2, 2012 #4
    temp(i,j) is an matrix containing pixel values of an image.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to write this code in matlab?
Loading...