Hi all(adsbygoogle = window.adsbygoogle || []).push({});

I'm new to matlab and am having trouble with a certain function, called score. I've looked at this for a while now and can't see where im going wrong?!

The fucntion scores the similarities of two matrices,

1 for a match

-1 for a non match

the code:

function s = Score(x,y,d)

% Score matirx for x and y in {1,2,3,4}

% Mismatch penalty = d

s = ((x==1)'*(y==1)+(x==2)'*(y==2)+(x==3)'*(y==3)...

+(x==4)'*(y==4))*(1+d) - d;

input:

x = ceil(4*rand(1,5))

y = ceil(4*rand(1,7))

[0 y; x' Score(x,y,1)]

..and that error...

??? Error using ==> _times_transpose

Function '*' is not defined for values of class 'logical'.

Error in ==> C:\MATLAB6p5p1\work\Score.m

On line 6 ==> s = ((x==1)'*(y==1)+(x==2)'*(y==2)+(x==3)'*(y==3)...

.. i;m not sure what it is?! i'm sure its something dumb.

Can you suggest a learning resource, my curernt approach is to go through online tutorials.

Thanks for your time

Snk_majin

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab help - alignment

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads for Matlab help alignment | Date |
---|---|

MATLAB MATLab: Not enough inputs for nlinfit | Nov 16, 2017 |

MATLAB Help needed to fix a matlab code | Nov 8, 2017 |

New to Matlab, help with vectors | Feb 20, 2016 |

Need help with integral | Dec 23, 2015 |

MATLAB 2D diffusion equation, need help for matlab code. | Nov 7, 2015 |

**Physics Forums - The Fusion of Science and Community**