Error using ==> fprintf Function is not defined for 'sym' inputs.

  • Follow


Hello,

I'm trying to output 3 points from a code I've written and I keep getting this same error when I run the code:

??? Error using ==> fprintf
Function is not defined for 'sym' inputs.

Below is the for loop I have created that I'm trying to run. Any suggestions or ideas? I've tried fwrite also and that didn't work either.

for x = (r_h/R):(1/10):1;
    for Ch = 0:((x/c)/10):(x/c);

%These are solved for earlier in the code
        VAR1 = EQS.A;
        VAR2 = EQS.B;
        VAR3 = EQS.C;
        VAR4 = EQS.D;
        VAR5 = EQS2.E;
        VAR6 = EQS2.F;
        VAR7 = EQS2.G;
        VAR8 = EQS2.H;
        
        EQUATION1 = (VAR1)*x.^3 + (VAR2)*x.^2 + (VAR3)*x + VAR4;
        EQUATION2 = (VAR5)*Ch.^3 + (VAR6)*Ch.^2 + (VAR7)*Ch + VAR8;
        
        Z = EQUATION1 * EQUATION2;
        
        fprintf(fid1,' %8.2f     %8.4f      %8.8f\n',[x; Ch; Z]);
        
    end
end

When I run the code and have x, Ch, and Z displayed I get numbers but once the code reaches the fprintf statement, the error occurs. So I know the equations are giving me numerical values just not sure why the code wont write them to a file.

Any help or comments would be of great help! Thank you.
0
Reply Devin 11/15/2010 2:37:03 AM


"Devin Witt" <snocross7609@yahoo.com> wrote in message 
news:ibq6cf$8fl$1@fred.mathworks.com...
> Hello,
>
> I'm trying to output 3 points from a code I've written and I keep getting 
> this same error when I run the code:
>
> ??? Error using ==> fprintf
> Function is not defined for 'sym' inputs.

That's correct; you will need to convert the SYM object into something 
FPRINTF understands (like a double or a char array) in order to print it.

*snip*

-- 
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on 
http://www.mathworks.com 

0
Reply Steven_Lord 11/15/2010 4:14:37 AM


1 Replies
1580 Views

(page loaded in 0.017 seconds)

Similiar Articles:













7/22/2012 10:53:33 PM


Reply: