Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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 vue (au cours des 30 derniers jours)
Hatef
Hatef le 7 Jan 2014
Clôturé : MATLAB Answer Bot le 20 Août 2021
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)');

Réponses (0)

Cette question est clôturée.

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by