you're trying yo use Baum.m before it is even defined. Just use an inline function at the top
Ok I got it to work.
Now how do I get it to work if A,B,D,E and F are 1x3 vectors?
So it plots 3 lines. One for the first, second and third values.
you aren't programming properly man. you don't put the variables inside a function like that. That second script will run if you delete the first line and the last line of your code(no need for it to be a function that takes arbitrary variables)
Here's how to do it with Baum as a function that can be used within the script.
Baum = @(T,A,B,D,E,F) (A+B)*(D/T/(sinh(D/T))).^2 ...
+ E*(F/T/(cosh(F/T))).^2;
T = 200:10:1500;
A= 0.7568*1e5;
B = 3.3924*1e5;
D = 1.496*1e3;
E = 2.247*1e5;
F = 675.9;
n = length(T);
X = zeros(n);
for i = 1:n
X(i) = Baum(T(i),A,B,D,E,F);
end
plot(T,X);
I know I'm retarded but it should be something like this right?
for vectors, just type in your vectors for A,B ... so on and change X to be X = zeros(3,n).
Then in the loop specify
X(1,i) = Baum(T(i), A(1,i), B(1,i) ...)
X(2,i) = Baum(T(i), A(2,i), B(2,i) ...)
X(3,i) = Baum(T(i), A(3,i), B(3,i) ...)
>>292912
if you want to do it like this then you need two loops and write X like this to get three columns:
X = zeros(length(T), length(A))
for i=1:length(T)
for j = 1:length(A)
X(i,j) = Baum(T(i), A(1,j), B(1,j) ...)
end
end
If you have to submit this somewhere, I would use the code I wrote as it is more sensible. You're writing kind of a non-function the way you're doing it, doesn't make sense.
>>292918
Not sure if that's how you meant it.
Still getting an error.
I get it but what do I do about it?
>error: Baum: quotient: nonconformant arguments (op1 is 1x3, op2 is 1x131)
>error: called from
> Baum at line 9 column 4
>>292922
You mean >>292911 ?
How would it work if A,B,D,E,F were 1x3 vectors?
I get that it can't calculate X while there's 1x3 and 1x131 vectors but I have no idea how to solve this.
>>292929
Now I did it like this.
Getting a new error though:
>error: max_recursion_depth exceeded
>error: called from
> Baum at line 14 column 11
Every time I work past one error I get a new one.
>>292934
>>293140
so you just need to get rid of the part that says 'function [X]'
and also the 'endfunction'
and this will run
>>293141
function [X] = *