Error using ==> vertcat CAT arguments dimensions are not consistent.

조회 수: 1 (최근 30일)
Hirak
Hirak 2013년 12월 19일
댓글: Hirak 2013년 12월 19일
Hi Friends, Thank you for your responses. Major of my work consists of generation of data plot. I am need for a code in which I can vary r_core and r_shell for a fixed value of r_core to find out g from the given equation:
  • g=[(r_core+r_shell)^3-r_shell^3]/(r_core+r_shell)^3
  • The range of r_shell is 1 to 5.2 with gap 0.26. In each case, the value of r_core is to be varied from 1:1:17. Plot should be r_shell in x-axis, r_core in y-axis and g in z-axis.I also need the data in tabulated form. My code was:
if true
clear all;
close all;
r_shell=(1:.26:5.2);
for r_core=(1:1:17);
g=((r_core+r_shell).^3-r_shell.^3)./(r_core+r_shell).^3;
end
tem=[r_shell;r_core;g]';
figure
meshgrid(1:.26:5.2,1:.1:17,g);
xlabel('Shell thickness(nm)')
ylabel('Particle radius(nm)');
zlabel('Murray g factor');
data = [r_shell;r_core;g];
save('data1.tab','tem','-ascii');
end
thank you all, Merry Christmas to you and your family. With love and regards, Hirak
  댓글 수: 2
Jos (10584)
Jos (10584) 2013년 12월 19일
It would be really helpful when you mention what the code is that produces the error ...
Hirak
Hirak 2013년 12월 19일
The error message is the topic itself

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 12월 19일
Please try this code:
r1 = (1:.26:5.2)';
r2 = (1:17)';
[i1,i2] = ndgrid(r1,r2);
g=((i2+i1).^3-i1.^3)./(i2+i1).^3;
mesh(i1,i2,g);
xlabel('Shell thickness(nm)')
ylabel('Particle radius(nm)');
zlabel('Murray g factor');
  댓글 수: 1
Hirak
Hirak 2013년 12월 19일
Thank you for your kind response. But I am facing a difficulty - using this code , there occur solution for g considering the respective values from each element of the matrix of r1 and r2. What I mean to say, this code computes the value for g taking (r1,r2) as (1,1),(1.26,2),(1.52,3)and so on. but I want to compute g taking the values of(r1,r2)as (1,1),(1,2).....(1.26,1),( 1.26,2)....(1.52,1),(1.52,2)..... for all the 17 elements,which in turn will result in 17*17=139 data points.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by