How to solve this equation with two variables in one equation ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Robert101
el 19 de Ag. de 2019
Comentada: Adam Danz
el 20 de Ag. de 2019
A = 1;
B = 1;
for n=0.0:0.1:1.0
for c = 0.0:0.1:1.0
c0 = 1.13e-4;
w = -A*(c-c0)^2*(n^4-3*n^2+2*n)+B.*(c-1)^2*n^2;
end
end
0 comentarios
Respuesta aceptada
Adam Danz
el 20 de Ag. de 2019
Editada: Adam Danz
el 20 de Ag. de 2019
Loop through index values rather than a vector of values.
Store each iteration in w(n,c) and pre-allocate w with NaNs.
A = 1;
B = 1;
c0 = 1.13e-4;
% Vectors to loop through
nVec=0.0:0.1:1.0;
cVec = 0.0:0.1:1.0;
w = nan(numel(nVec),numel(cVec)); %pre-allocate with NaNs
% Loop through each element of nVec
for n=1:numel(nVec)
% Loop through each element of cVec
for c = 1:numel(cVec)
w(n,c) = -A*(cVec(c)-c0)^2*(nVec(n)^4-3*nVec(n)^2+2*nVec(n))+B.*(cVec(c)-1)^2*nVec(n)^2;
end
end
w(n,c) is the result for inputs nVec(n) and cVec(c)
6 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Contour Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!