I have used MATLAB for few hours.So I don't know the differences

between version 6.5 and 7.0.I want to use some codes of MATLAB 7.0,

but they doesn't work in MATLAB 6.5.How to change these codes so that

they can work in matlab 6.5.Waiting for your help. Thank you .

The codes are like this .I think changing the function findPI may

work ,but I don'y know how

% PIfun.m

% Evaluate a function used to find the PI-line, using Kyle Champley's

% method.

%

% Adam Wunderlich

% last update: 5/18/06

function y = PIfun(r,R,h,gamma,x3,sb)

temp = R - r*cos(gamma-sb);

y = h*((pi - 2*atan(r*sin(gamma-sb)/temp))*(1 + (r^2 - R^2)/

(2*R*temp)) ...

+ sb) - x3;

% find_PI_Line.m

%

% Find the the parametric interval corresponding to the unique PI-line

% passing through the point x for a given helical pitch.

% This code implements the method of Kyle Champley.

% inputs: P = pitch (cm/turn), R = helix radius, delta_s = s stepsize,

x

% output: PI = [sb st]

%

% Adam Wunderlich

% last update: 5/18/06

function [PI] = findPI(P,R,delta_s,x)

h = P/(2*pi);

r = sqrt(x(1)^2+x(2)^2);

gamma = atan2(x(2),x(1));

options = optimset('TolX',h*delta_s/100,'FunValCheck','on');

[sb,fval,exitflag] = fzero(@(sb) PIfun(r,R,h,gamma,x(3),sb),...

[(x(3)-h*pi)/h,x(3)/h],options);

if exitflag ~=1,

disp('Error: PI invalid');

end

% note that beta=sb in Kyle's formula

alphaX = atan(r*sin(gamma-sb)/(R - r*cos(gamma-sb)));

st = sb + pi - 2*alphaX;

PI = [sb st];

Where exactly are you having a problem? Is there a compilation error?

At which line? I am assuming you tested it in Matlab 7, and it works

fine?

At which line? I am assuming you tested it in Matlab 7, and it works

fine?

thanks for your answer

You konw I want it to work in Matlab 6.5 not Matlab7 but it doesn't

I have called this function :

PI(i,j,k,:) = findPI(P,R,delta_s,[x(i) y(j) z(k)]);

I get this

??? Error: File: C:\MATLAB6p5\work\fbp\findPI.m Line: 20 Column: 29

"identifier" expected, "(" found.

Error in ==> C:\MATLAB6p5\work\fbp\flat_plain.m

On line 362 ==> PI(i,j,k,:) = findPI(P,R,delta_s,[x(i)

y(j) z(k)]);

Hi

Are you sure this worked under Matlab 7? Because this kind of error is

often something wrong in your code, not something because of a change

in matlab... In the line 362, there is a problem at function call. Try

making a test program, and pass values instead of variables, to see if

your function works. If it does, there is something wrong in the way

you are calling it. If you still get an error, check your function...

Are you sure this worked under Matlab 7? Because this kind of error is

often something wrong in your code, not something because of a change

in matlab... In the line 362, there is a problem at function call. Try

making a test program, and pass values instead of variables, to see if

your function works. If it does, there is something wrong in the way

you are calling it. If you still get an error, check your function...

*snip*

Anonymous functions, as this code uses, were introduced in MATLAB 7.0 (R14).

They were not available in MATLAB 6.5 (R13), so you cannot use them in that

version of MATLAB. You will need to rewrite this code to use a regular

function handle or an inline function with the P1, P2 syntax given in HELP

FZERO. This document will also help you modify the code:

http://www.yqcomputer.com/

The first half of the Solution section deals with MATLAB 7.0 (R14) and

later; the second half deals with versions of MATLAB prior to 7.0.

I very briefly scanned the code, but I didn't see anything else that looked

like it obviously wouldn't work in MATLAB 6.5. That doesn't mean there

aren't any, though.

--

Steve Lord

XXXX@XXXXX.COM

Hi

Thank you very much .

I will have a try .

1. Fminsearch works differently in MATLAB 6.5 and 7.0.x

2. Can Matlab 6.5 automatically convert GUI-based Matlab program to stand-alone applications?

3. save in matlab 6 and load in matlab 6.5: how to?

4. convert a .mat file (Matlab 6.5) to a .mat file(Matlab 4)

5. fsolve - Matlab 6.5 & Matlab 7

6. load5 - A solution to reading Matlab 7 files in Matlab 6.5

7. ode45 & events : error in Matlab 7 SP1, oke in Matlab 6.5

8. Matlab 6.5, Matlab Compiler 3.0, Multithreading with C++

9. converting matlab 7 files to matlab 6.5

10. From Matlab 6.5 R13 to Matlab 7

11. How can I execute a GUI app. done on matlab 6.5 to matlab 6.1

12. MATLAB 6.5 Toolboxes in MATLAB 7

13. Read Matlab 7 .mat files in Matlab 6.5 -- SOLUTION

15. Convert GUI of Matlab R2006a&b to Matlab 6.5

6 post • Page:**1** of **1**