Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How can i save the outputs of a function inside that function so i can recall that function in another script and plot with it output ???

1 Ansicht (letzte 30 Tage)
function [x] = compute(W, k1, k2, d)
x1 = W / k1; x2 = ( W + 2 * k2 * d ) ./ ( k1 + 2 * k2 ); k1 = 10000; k2 = 15000; d = 0.1;
if x1 < d;
x = x1;
else x = x2;
end
this is my first function, after i set the value W i get an output, now i want to save that output inside this function so i can use it in my next script which is this one:
W = 0:50:3000;
k1 = input ('Please enter a value for k1=', 's');
k1 = str2num(k1);
a = isempty(k1);
while a == 1;
k1 = input('Wrong Input!!! Please enter a value for k1=' , 's');
k1 = str2num(k1);
a = isempty(k1);
end
while a == 0;
k2 = input('Please enter a value for k2=','s');
k2 = str2num(k2);
b = isempty(k2);
while b == 1;
k2 = input('Wrong Input!!! Please enter a value for k2=','s');
k2 = str2num(k2);
b = isempty(k2);
end
while b == 0;
d = input('Please enter a value for d=','s');
d = str2num(d);
c = isempty(d);
while c == 1;
d = input('Wrong Input!!! Please enter a value for d=','s');
d = str2num(d);
c = isempty(d);
end
if c == 0;
end
break;
end
break;
end
x = compute(W, k1, k2, d);
plot(W, x);
xlabel('Distance(m)');
ylabel('Weight(N)');

Antworten (0)

Diese Frage ist geschlossen.

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by