How to write this code in matlab?

  • Context: MATLAB 
  • Thread starter Thread starter vikky_manit
  • Start date Start date
  • Tags Tags
    Code Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 3K views
vikky_manit
Messages
3
Reaction score
0
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.
 
Physics news on Phys.org
What is temp()? What is your expected output?

In code tags:
Code:
M0=100;
var0=100;

i[/color]=1:478;
j[/color]=1:448;
[b]if[/b][/color](temp(i[/color],j[/color])>[/color]M)
    G(i[/color],j[/color])=M0+[/color]sqrt[/color](double((var0*[/color]power((temp(i[/color],j[/color])-[/color]M),2))/[/color]V));
[b]else[/b][/color]
    G(i[/color],j[/color])=M0-[/color]sqrt[/color](double((var0*[/color]power((temp(i[/color],j[/color])-[/color]M),2))/[/color]V));
[b]end[/b][/color]
 
temp(i,j) is an matrix containing pixel values of an image.